Difference between glewGetString(GLEW_VERSION) and glewIsSupported

1.8k views Asked by At

I created OpenGL context on Windows 7 machine as described on https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL) .

Context was created successfully, but there seems to be some problems.

Since I need vertex/fragment shaders, I need at least OpenGL version 2.0 (or some extensions). After context is initialized and glewInit is called, I checked OpenGL context version using following commands:

  1. glewGetString(GLEW_VERSION) which returns "1.9.0"
  2. glewIsSupported("GL_VERSION_2_0") which returns 1

It seems odd that two GLEW functions report differend version. Both are (partially) explained on http://glew.sourceforge.net/basic.html .

Also I think that OpenGL version should be at least 4.0 for nvidia gtx 460. I'd also like to add that all shader/program function pointers (eg. glUseProgram) are not NULL pointers, and they work.

Is there a reliable way to tell the OpenGL version for created context?

Edit: Ok here is the solution. It seems that OpenGL/GLEW have similar function/parameter names which return different versions. This is the summary:

  1. glewGetString(GLEW_VERSION) returns GLEW version
  2. glGetString(GL_VERSION) returns OpenGL version but works only for OpenGL below version 3.0
  3. glewIsSupported("GL_VERSION_2_0") checks if OpenGL version 2.0 is supported
  4. if (GLEW_VERSION_2_0) checks if OpenGL version 2.0 is supported (not GLEW!!!)
  5. glGetIntegerv(GL_MAJOR_VERSION)​ and glGetIntegerv(GL_MINOR_VERSION)​ return OpenGL version, but are available only on OpenGL 3.0 and up

Regards

1

There are 1 answers

3
BDL On BEST ANSWER

These two methods do not return the same information:

glGetString(GLEW_VERSION) returns the version of the GLEW library, not the OpenGL Version used. In contrast, glewIsSupported checks whether a OpenGL Version is supported or not.

In order to get the OpenGL Version used in a context, one can use the glGetIntegerv function providing GL_MAJOR_VERSION and GL_MINOR_VERSION as first parameter.