[GLEW] Check available OpenGL version

Started by
3 comments, last by Jan2go 9 years, 11 months ago

The GLEW documentation states that you can check the available OpenGL version like this:


if (GLEW_VERSION_1_3)
{
  /* Yay! OpenGL 1.3 is supported! */
}

So, as my code is using OpenGL 3.0 i used GLEW_VERSION_3_0 to see if the computer can run the program. However, when I tested it on an Thinkpad which uses an integrated Intel graphics card with support only up to OpenGL 2.1. GLEW_VERSION_3_0 was for some reason evaluated as true. Querying GL_MAJOR_VERSION and GL_MINOR_VERSION as well as GL_VERSION show the correct result (OpenGL 2.1).

I tested other GLEW_VERSION_X_X macros on this computer, you can see the results in the attached file.

Has anybody else experienced this before? It's not a big deal to create a workaround for it but I wonder what might cause it and if it happens on other graphic cards as well.

Advertisement

Try using


glewIsSupported("GL_VERSION_3_0");

etc, instead of checking the version macros directly.

Querying GL_MAJOR_VERSION, GL_MINOR_VERSION, GL_VERSION will not give you available OpenGL versions in the driver but the version of the context you already created. Also GL_MAJOR_VERSION and GL_MINOR_VERSION were introduced in OpenGL 3.0 as far as I know, so they might not be a good way of checking the version on contexts created with earlier GL versions.

You could also try to run another OpenGL capabilities viewer like http://www.realtech-vr.com/glview/ to compare results.

Using glewIsSupported gives the same results als GLEW_VERSION_X_X. However, if GL_MAJOR_VERSION and GL_MINOR_VERSION return the OpenGL version of the created context, i could use that information the exit the program, if the created context is not at least of version 3.0.

I will try the Extension Viewer later, the download is via FTP and for some reason FTP is blocked here.

There seem to be two sets of defines for GL versions in GLEW, a bit confusing really:

"GLEW_VERSION_x_x" vs. "GL_VERSION_x_x"

In my code I am using the "GL_VERSION_x_x" ones with "glewIsSupported" and so far haven't had any problems on multiple test machines.

At least according to this post on Stackoverflow the "GL_VERSION_x_x" ones seem to work better indeed (for whatever reason)

http://stackoverflow.com/questions/21644230/what-is-the-difference-between-glew-version-x-x-and-gl-version-x-x

I guess your idea to just try to create contexts of a certain version and see if it succeeds or fails seems like a good way to check as well. Just on intel (and maybe other vendors) I've seen situations where it would create the context just fine but then not actually support the full GL spec for that particular version. Good times :)

Ok, I downloaded and installed the extension viewer. Not very usefull on this computer though, it crashes during the "Loading extensions..." part. :D

This topic is closed to new replies.

Advertisement