Debugging with glGetError

With OpenGL, one of the first ways to troubleshoot a problem is by checking if we made a call or passed in an argument that OpenGL didn’t like. We can do this by calling glGetError to get the state of OpenGL’s error flags. Here are some of the most common error codes:

GL_INVALID_ENUM

We passed in a value to a function that doesn’t accept that value. For example, maybe we passed in GL_FLOAT to glEnable or something else that doesn’t make sense for that function.

GL_INVALID_VALUE

One of the numeric arguments we passed in to a function was out of range.

GL_INVALID_OPERATION

We tried to perform an invalid operation for the given OpenGL state.

In addition to glGetError, we also have more specific ways of looking for an error, ...

Get OpenGL ES 2 for Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.