I haven’t thought this out very well, but has anyone tried wrapping OpenGL calls and adding conditionally compiled error checking? The general idea is that you could compile with a debug switch if you were having problems but couldn’t pinpoint the GL error. It would take a little time to set up, but you could create a header file that contained all of the OpenGL calls wrapped something like this:
void _glTranslatef(float x, float y, float z)
{
glTranslatef(x, y, z);
#ifdef DEBUG_OPENGL
// check GL errors here
#endif
}
You could compile out the obvious performance hit of the error checking, and if you’re compiling with a C++ compiler the wrapper function itself should be inlined, so you shouldn’t see a performance hit.
Hmmm…you might even be able to do this with a Perl script that parses the OpenGL header file and generates your wrapper header file automagically.
Is this a stupid idea? What would be the drawbacks?
[This message has been edited by starman (edited 06-18-2003).]