Detect OpenGL version?

BlitzMax Forums/OpenGL Module/Detect OpenGL version?

Grisu(Posted 2012) [#1]
Hello everyone!

Is there a proper way to detect which OpenGL version is currently used (cross-platform) by an app?

My example code below seems to fail on my machine.



Thanks in advance
Grisu


matibee(Posted 2012) [#2]
You can do it with a glGetString call, but just testing this and it only works if there is a current graphics context....

Framework BRL.Max2D
Import BRL.GLGraphics
Import BRL.GLMax2D
Import BRL.StandardIo

SetGraphicsDriver GLMax2DDriver()

' must have a graphics context!!
Graphics 800, 600

Print String.FromCString( glGetString( GL_VERSION ) )



Grisu(Posted 2012) [#3]
Thanks for the reply.

Won't the GL_Version only ouput the gfx-card capabilities?
In my case : "4.2.11762 Compatibility Profile Context" = a version below 4.2 - and not what is actually used?

Anyway, I need a solution that works with maxgui apps. When setting this string output within a "SetGraphics CanvasGraphics()" context, it fails.


matibee(Posted 2012) [#4]
Surely your initial code is only a compile time test because GL_VERSION_nnnn would have to be Const's defined somewhere in the headers?

If you want a compile time string you'd probably have to look in the mingw/opengl/glew headers or the opengl mod. This will tell you what version of opengl you are compiling against.

The glGetString method works fine in my maxgui app and will tell you what version of openGL the video card drivers are running.


Grisu(Posted 2012) [#5]
The const's were taken out of the glew mod. As you stated, this was only for testing purposes.

Anyway, got it working now. - Thanks everyone!