How to check error in GLEW

You typically check for error after initializing GLEW by calling glewInit(). It returns an error value of type GLenum. Note that GLEW merely uses this data type, it has defined its own error values based on it.

By looking at GLEW header files, I find that the error values currently supported are:

#define GLEW_OK 0
#define GLEW_NO_ERROR 0
#define GLEW_ERROR_NO_GL_VERSION 1  /* missing GL version */
#define GLEW_ERROR_GL_VERSION_10_ONLY 2  /* Need at least OpenGL 1.1 */
#define GLEW_ERROR_GLX_VERSION_11_ONLY 3  /* Need at least GLX 1.2 */

So, you typically first check if the value returned from glewInit() is GLEW_OK. If not, you further investigate what the error might be.

GLEW provides an utility function glewGetErrorString() that provides an error string given the error value.

Putting all the above together, this is how we could check for error in GLEW:

const GLenum err = glewInit();

if (GLEW_OK != err)
    std::cout << "GLEW Error: " << glewGetErrorString(err) << std::endl;

Tried with: GLEW 1.10 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.