Checking if a feature is supported by the current driver

Started by Klemss, July 16, 2012, 02:27:12

Previous topic - Next topic

Klemss

Hi !

I've runned into some issues with my current computer (a notebook). Mainly shaders programs can't get linked and FBO aren't supported.
I'm pretty sure that's because of the drivers or the GPU itself, but that isn't the question. Is there any way to know if a feature is supported by the current driver ?
I could catch an Exception but what if the function DOESN'T throw an exception and crash outside the JVM ?

I'm creating a FBO wrap to draw metaball (rendering additive non-linear sprites on a FBO + rendering on scene with alpha test on). If FBO aren't supported, I could simply draw sprites instead of crashing the program.

EDIT: I've found a way to do it with "GL11.glGetString(GL11.GL_VERSION).split("\\.");" and parsing the two first String as an integer.



Unrelated but my GPU (GMA 4500M) is supposed to be able to run shaders. I can compile shaders and attach them to a program, but the function glLinkProgram always result in a driver crash. Isn't the function supposed to throw an "IllegalStateException: Function is not supported" ? I'm going to try on another computer.

moci

Just to be sure, the shaders you are linking are compiled successfully? You can check this by calling "GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS)".

Klemss

Quote from: moci on July 16, 2012, 13:00:29
Just to be sure, the shaders you are linking are compiled successfully? You can check this by calling "GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS)".
Yep, no problem here.
It return GL_TRUE and glGetShaderInfoLog(shader, 1024) return "No Errors."

EDIT: Wait, no. There were a BOM in the shader source file. Maybe OpenGL isn't supposed to take a non-ascii String (written in C and C strings are ASCII), that would explain things. It solved the crash, thanks a lot.
EDIT2: Somehow the compiler doesn't like comments too... I'm not sure why. Also result in a native crash instead of a compilation error.

FoolMeOnce

Not sure if you're still looking for an answer, but GLView is a useful program for checking if openGL features are supported.
You can find it at http://www.realtech-vr.com/glview/.
I haven't used it a lot and it can be glitchy, but it seems to do what you need.

princec

The normal way to check in LWJGL is to ask LWJGL rather than go parsing the string yourself:
if (GLContext.getCapabilities().GL_EXT_secondary_color) {
...
}

Every supported extension is queried in the same way. If it returns true, you've got the extension and can use all the functions.

Cas :)