PDA

View Full Version : using GLSL 3.30 in OpenGL 4.x context



somboon
10-16-2010, 10:58 PM
Is it possible to use GLSL 3.30 code in OpenGL 4.0 context ?

or all the shader have to be declare version 400 ?

I ask this because I haven't own any GL4 capable card yet and I want to add OpenGL 4 code path (tessalation) to my existing OpenGL 3.3 renderer with out having to seperate all the shader in to 2 version(330,400).

Alfonse Reinheart
10-17-2010, 01:29 AM
Of all the potential problems with GLSL, one that I have never heard of is a higher version of OpenGL not supporting a lower shader version (except where core/compatibility issues arise, and that only happens when using deprecated GLSL features).

The 4.0 specification itself only requires that GLSL v4.00 be supported; other versions can be optionally supported. In reality, I seriously doubt that any OpenGL implementation will care. They'll just use the version tag to decide what can and cannot be used.

If for no other reason that the fact that context creation doesn't ensure that you will get a 3.3 versions. The context creation extension specifically says that, if you ask for a 3.3 version, you'll get 3.3 or the highest version that is completely backwards compatible with it. Which nowadays is 4.1.

However, I would point out that 3.30 doesn't allow for the things you need for tessellation. That is, you can't compile tessellation shaders for version 3.30. And I'm not sure what the GLSL protocol is for linking shaders with different GLSL versions.

If you do find the version issue to be significant, you can always remove the version number from the shader file entirely. Just pass a string before your main shader string(s) to the string setting function that has "#version 3.30" or "#version 4.00" as needed.

somboon
10-17-2010, 02:59 AM
Thank for your answer.

I plan to implement the tessellation code path in OpenGL 4/GLSL 440 that will only be usable when user explicitly request 4.0/4.1 context (on a support hardware).