GL Errors

When OpenGL detects an error, it will not do anything obvious like printing an error message.

Instead, it saves the current error code, and ignores the command that caused the error.

It's highly recommended to check the GL error state every so often, and print a warning if there is an error.

Use a function like:

void checkGLError(char *prefix)
    {
    GLenum err = glGetError();
    if (err != GL_NO_ERROR)
        printf("%s GL error '%s'\n", prefix,
               gluErrorString(err));
    }

At a minimum, you could call checkGLError("end-of-frame"); at the end of your drawing function. If you start getting error reports and don't know what's causing them, you can then add further checkGLError calls within the drawing function until you find the culprit.


next