Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Jul 18, 2025 14:53

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 6 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Jedi SDL + dglOpenGL.pas
BeitragVerfasst: Mo Feb 07, 2005 13:09 
I tried using dglOpenGL.pas with the SDL demos.
Replacing the unit OpenGL12.pas with dglOpenGL.pas and making the required changes so it compiles.
When running the application, as soon as any OpenGL call is made I get a access violation.
Anyone have a idea of what is the cause of this and how it can be fixed?


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Feb 07, 2005 13:28 
Offline
DGL Member

Registriert: Mi Dez 15, 2004 20:36
Beiträge: 454
Wohnort: Wien, Österreich
Code:
  1.  
  2. unit Unit1;
  3.  
  4. interface
  5.  
  6. uses
  7.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  8.   Dialogs, dglopengl;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     procedure FormCreate(Sender: TObject);
  13.     procedure FormDestroy(Sender: TObject);
  14.     procedure FormResize(Sender: TObject);
  15.     procedure FormPaint(Sender: TObject);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.     procedure glInit();
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.   mydc,myrc:cardinal;
  26.  
  27. implementation
  28.  
  29. {$R *.dfm}
  30.  
  31. procedure Tform1.glInit();
  32. begin
  33.   glClearColor(0.3, 0.3, 0.3, 0.0);        // Black Background
  34.   glShadeModel(GL_SMOOTH);                 // Enables Smooth Color Shading
  35.   glClearDepth(1.5);                       // Depth Buffer Setup
  36.   glEnable(GL_DEPTH_TEST);
  37.   glDepthFunc (GL_LEQUAL);
  38. //  glEnable( GL_CULL_FACE );
  39. //  glCullFace( GL_FRONT );
  40.   glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);   //Realy Nice perspective calculations
  41.   glEnable(GL_TEXTURE_2D);                     // Enable Texture Mapping
  42.   wglSwapIntervalEXT(0);
  43. end;
  44.  
  45. procedure TForm1.FormCreate(Sender: TObject);
  46. begin
  47.  mydc := getdc(handle);
  48.  InitOpenGL();
  49.  myrc := CreateRenderingContext(mydc,[opDoublebuffered],32,24,0,0,0,0);
  50.  ActivateRenderingContext(mydc, myrc);
  51.  glInit();
  52. end;
  53.  
  54. procedure TForm1.FormDestroy(Sender: TObject);
  55. begin
  56.  DeactivateRenderingContext;
  57.  DestroyRenderingContext(myrc);
  58.  releasedc(handle,mydc);
  59. end;
  60.  
  61. procedure TForm1.FormResize(Sender: TObject);
  62. begin
  63.  if Height=0 then Height:=1;
  64.  
  65.   glViewport(0, 0, Width, Height);    // Set the viewport for the OpenGL window
  66.   glMatrixMode(GL_PROJECTION);        // Change Matrix Mode to Projection
  67.    glLoadIdentity();                   // Reset View
  68.     gluPerspective(45.0, Width/Height, 1.0, 1000.0);  // Do the perspective calculations. Last value = max clipping depth
  69.  
  70.   glMatrixMode(GL_MODELVIEW);         // Return to the modelview matrix
  71.    glLoadIdentity();                   // Reset View
  72.  
  73.    //if needed a faster feedback
  74.    OnPaint(self);
  75. end;
  76.  
  77. procedure TForm1.FormPaint(Sender: TObject);
  78. begin // this is only an alternative....OnIdle for intensiv drawing
  79.  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  80.    glLoadIdentity();
  81.    //--draw the scene
  82.  
  83.    //--draw then scene
  84.  SwapBuffers(mydc);
  85. end;
  86.  
  87. end.
  88.  

_________________
"Meine Mutter sagt : 'Dumm ist der, der Dummes tut'." - Forrest Gump


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Feb 07, 2005 13:40 
Thank you, but I create the window using SDL calls.
What I did notice is this call
ActivateRenderingContext(mydc, myrc);

I don't have this in my code.
So does anyone know how I can extract the DC and HDC from SDL for use in this call?


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Feb 07, 2005 15:32 
Offline
DGL Member

Registriert: Mi Dez 15, 2004 20:36
Beiträge: 454
Wohnort: Wien, Österreich
Zitat:
ActivateRenderingContext(mydc, myrc);

Without this line you can´t go on, because that is the place where all the functions pointer of OpenGL library are loaded. That is the reason why you get "Access violation" message, all pointers are = NIL. So any call to glXXX is a Access violation itself.
And sorry i can´t help you, have no knowlege on SDL.

_________________
"Meine Mutter sagt : 'Dumm ist der, der Dummes tut'." - Forrest Gump


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Feb 07, 2005 15:38 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Phobeus made this Tutorial about SDL and OpenGL. There are some sources. May it can helps.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Feb 07, 2005 15:52 
Your answer is good enough, thanks a bundel.


Nach oben
  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 6 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 5 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.022s | 15 Queries | GZIP : On ]