Which method to get OpenGL version?

I need a method that returns the OpenGL version of the computer …

I want to do it:

public void setRenderer(){
    if(glVersion >= 3){
    if(glVersion == 2){
    if(glVersion == 1){

Thus, it is automatically configured to use the renderer using the PC version of OpenGL that is running the game!


If you use opengl3 features you need opengl3,
same for 2.
1 is pretty limited as far as I know.

So if you do not use opengl3 settings just use 2, else use 3.

No one knows which method returns the version of OpenGL? :fearful:

jME3 already does automatically what you mentioned. The renderer selection is to select a “minimum” version to target against.

So why when I run a code without


I get an error saying that it is necessary to GLSL and OpenGL 2.0?

in short opengl1 is not supported, as like zero features of the engine work on it.

If you need a opengl1 compatible engine, you can either use jme2 or think about your requirements again.

OpenGL 1.x is no longer supported as of jME3.1, so either way you’ll need to either find a driver for your OS which supports it, or check your hardware manufacture date, if it is 2006 or earlier, you cannot run jME3.1 on it.

Oh no, it means I’ll have to stay in jME 3.0 :cry:

No one answered my question … Please I need an answer!


Do you need to support hardware manufactured in 2006 and earlier?

JME is built off java. Would System.getenv(“Argument”) work ?

In order to directly answer the question then.

If you’re using LWJGL and you’re happy bypass JME API and you are willing to live with the fact that the LWJGL API will most likely change in the next major version (3.x) then you can do something like this.

if (GLContext.getCapabilities().OpenGL30) {
    // OpenGL 3+
} else if (GLContext.getCapabilities().OpenGL20) {
    // OpenGL 2+
} else {
    // Probably OpenGL 1

Thanks! Then I will test this code!

Also don’t forget there’s LWJGL_OPENGL_ANY which automatically chooses the appropriate version for you - do note its a jME 3.0 only feature.

Oh, then use LWJGL_OPENGL_ANY seems the best choice. Thank you!