any tips how i'd track down a bug like this ? i'm getting one per
frame, it looks like.
from squeak3d.log:
ERROR (file sqOpenGLRenderer.c, line 409): a GL function failed --
GL_INVALID_ENUM
Well, debugging these issues goes roughly like follows:
* You go to squeak.hpl.hp.com and choose to "browse the VM repository"
* Here you navigate to
trunk/platforms/Cross/plugins/B3DAcceleratorPlugin
* Look at sqOpenGLRenderer.c to find line 409 (you probably have to
download the file and use a reasonable text editor to find it)
* Line 409 is in glSetTransform:
407: DPRINTF(5, (fp, "### Installing new transformations\n"));
408: glMatrixMode(GL_PROJECTION);
409: ERROR_CHECK;
So it looks like glMatrixMode() is failing, right? Wrong! The
ERROR_CHECK macro uses glGetError() and glGetError() will keep the
error around until it has been reported. So the only thing we know is
that sometime *before* the method was called the error has occured.
Time to look at the Squeak side.
The easiest (and likely best) thing to do is to throw in an occasional
glGetError() check in your own code and print it to the transcript.
Here is a safe way way of doing this:
printError: ogl
err := ogl glGetError().
err = 0 ifFalse:[
WorldState addDeferredUIMessage:[
Transcript cr; show: 'OpenGL error: ', err hex.
].
].
This will print out any errors and from here it's basically divide and
conquer - just use binary search (or random guesses ;-) to narrow down
where the error occurs.
The exercise left for the reader: Write a OpenGLErrorTrap class which
automatically checks for the first occurance of a glGetError() after
invoking any of the OpenGL methods. Hint: Make it a ProtoObject
subclass and learn more about proxies ;-)
Cheers,
- Andreas