How do I get OpenGL errors?

BlitzMax Forums/OpenGL Module/How do I get OpenGL errors?

ImaginaryHuman(Posted 2006) [#1]
I open a valid display, and initialize all the OpenGL view ready to start drawing.

Then I do this:

repeat
until glGetError()=0  'wipe existing errors
glCopyPixels(0,0,8,8,GL_STENCIL)
If glGetError()>0 Then Print "Error copying in stencil buffer - no stencil buffer" Else Print "No error"


However, this always shows "No error", regardless of whether I have a stencil buffer available or not (as set up with flags in CreateGraphics().

How can I get the error? According to the OpenGL blue book, "GL_INVALID_OPERATION is generated if type is GL_STENCIL and there is no stencil buffer."

But I always get GL_NO_ERROR.

?????????


ImaginaryHuman(Posted 2006) [#2]
Although CopyPixels() does not appear to return an error, glReadPixels() does. This is a way to test if there is really a stencil buffer. If you asked for a stencil buffer and this says there isn't one, you know your display is corrupt and not working - so you can go to a different mode/window.

Repeat
Until glGetError()=GL_NO_ERROR 'wipe errors
Local bb:Int
glReadPixels(20,20,1,1,GL_STENCIL_INDEX,GL_UNSIGNED_BYTE,Varptr(bb))
If glGetError()<>GL_NO_ERROR Then Print "Error reading from stencil buffer, we cab tell there is no stencil buffer!" Else Print "No error - we can tell there must be a stencil buffer!"