DGL
https://delphigl.com/forum/

dglOpenGL in gDEBugger GL: errors
https://delphigl.com/forum/viewtopic.php?f=19&t=10939
Seite 1 von 1

Autor:  s73 [ Fr Aug 09, 2013 20:09 ]
Betreff des Beitrags:  dglOpenGL in gDEBugger GL: errors

There is errors shown by gDEBugger with program using dglOpenGL like "Debug String: Detected error: The debugged process asked for an extension function pointer (glPrimitiveRestartIndex) from one render context, but called this function pointer in another render context (context #1)" (same for glGenBuffers, glBindBuffer etc).

Initialization code
Code:
  1.  
  2. procedure TFormMain.FormCreate(Sender: TObject);
  3. ...
  4. begin
  5.   InitOpenGL; // Don't forget, or first gl-Call will result in an access violation!
  6.   dc := GetDC(Handle);
  7.   hrc := CreateRenderingContext(dc, [opDoubleBuffered], 32, 24, 0, 0, 0, 0);
  8.   ActivateRenderingContext(dc, hrc); // Necessary, will also read some extension
  9.  
  10.   glEnable(GL_TEXTURE_2D);
  11.   glEnable(GL_PRIMITIVE_RESTART);
  12.   glPrimitiveRestartIndex(VERTEX_RESTART_INDEX);
  13.   glEnableClientState(GL_NORMAL_ARRAY);
  14.   glEnableClientState(GL_VERTEX_ARRAY);
  15.   glEnable(GL_DEPTH_TEST);
  16.   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  17.  
etc

Autor:  Stucuk [ Fr Aug 09, 2013 23:10 ]
Betreff des Beitrags:  Re: dglOpenGL in gDEBugger GL: errors

If you only activate one rendering context then its impossible for that to happen. The extensions are loaded after the first call to ActivateRenderingContext. So they will be used by that context until you call it again (Or use wglMakeCurrent).

Autor:  s73 [ Sa Aug 10, 2013 08:45 ]
Betreff des Beitrags:  Re: dglOpenGL in gDEBugger GL: errors

Only one context, I see all rendering results. I think (by searching stackoverflow, similar question) those another context from extensions for higher like OpenGL 3.3 functions:
Zitat:
The function pointers you get are based on the current context. That is, it is entirely possible for you to get different function pointers for different OpenGL contexts. gDEBugger is telling you that it has detected that you're using function pointers with a different context from the one used to acquire them. Which is not guaranteed to work.

That being said, it generally will work. It won't work if the two contexts aren't from the same vendor (and probably for the same GPU or SLI/CrossFire GPU setup). But if they are, it should be fine.
http://stackoverflow.com/questions/9663 ... indows-api

Autor:  mori [ Sa Aug 10, 2013 10:35 ]
Betreff des Beitrags:  Re: dglOpenGL in gDEBugger GL: errors

You are right with your assumption about the contexts. There was a similar question a few weeks ago http://www.delphigl.com/forum/viewtopic.php?f=10&t=10874 (ger). OpenGL needs a special context for 3.x and higher versions which can only be requested by another context with a version less than 3.x. In general the function pointers should work for both contexts. An solution would be, to request all function pointers again from OpenGL (which is otherwise automatically done by the header for the first context) and overwrite all the gl-Functions with the new context specific pointers.

Autor:  s73 [ Sa Aug 10, 2013 10:39 ]
Betreff des Beitrags:  Re: dglOpenGL in gDEBugger GL: errors

Thanks.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/