Checking if a certain version is available on the system

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Checking if a certain version is available on the system

ColaColin
Hi,

I have an application that wants to query "is open gl 3.30 availble" and only then initialize a Window with an OpenGL render path. If it is not available it will create a java2d based fallback instead.

So I need a function with this interface:

public static boolean isGLSLSupported(com.jogamp.common.util.VersionNumber vn);

The only way I came up with however seems rather cluncky:

http://pastebin.com/mUSncfE0

I then call it like this:
System.out.println("#version 330 core is supported: " + isGLSLSupported(new VersionNumber(3, 30, 0)));

I am not quite sure if this is even a correct way to do this, can anybody verify if this at least works? As clunky as it is I feel uneasy doing this ;)


Reply | Threaded
Open this post in threaded view
|

Re: Checking if a certain version is available on the system

gouessej
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Checking if a certain version is available on the system

ColaColin
So I've tried this code now:

        private static boolean canRunOpenGL() {
                GLProfile prof = GLProfile.getDefault();
                return prof.isGL3() && prof.hasGLSL();
        }

That seems to do the trick on a netbook I have.
On a laptop of another person however this returns true and then proceeds to fail to actually compile the version 330 core shaders with these messages:

http://i.imgur.com/xVQLumk.png

Can I detect that as well with the GLProfile stuff? Or will I need to even extend my code from above to test if it can compile the shaders?
Reply | Threaded
Open this post in threaded view
|

Re: Checking if a certain version is available on the system

gouessej
Administrator
You can call glAvailabilityToString() but you'll have to look for information into the returned string by yourself.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Checking if a certain version is available on the system

ColaColin
I run a testprogram: http://pastebin.com/G8e6PqDn

The output on the problematic laptop is:

can run OpenGL 4: false
can run OpenGL 3: true
GL version is 3.2 (Core profile, arb, compat[], FBO, hardware) - 3.2.9262 Core Profile Context
GLSL version number is 1.50.0
GLSL version check for 3.30 returns: false

So it's exactly one minor version away from supporting OpenGL 3.3. I guess the test for GL3 returns true for any 3.x version, which is not enough to determine if 3.3 is available.

I think I will first check if OpenGL 4 is available and if it is not available create a fake window to create a GLContext that I can ask for the exact supported version.

Thanks for the help