GLSL versions

Many (all?) OpenGL drivers support different versions of GLSL and some applications support more than one version of GLSL. But what is the guaratee, that the GLSL version(s) an application supports is going to be supported by the GL on the unknown user platform? What is the key based upon which an application writer decides which GLSL versions to support? I suppose one could be: support the lowest GLSL version allowing all required features of the application?

“support the lowest GLSL version allowing all required features of the application” that is a start.
If that is too restrictive, plan a GLSL 1.5 version + a GLSL 1 with some features removed as fallback (for example).

How about this idea:

  • “crappy” features supported by low GLSL versions,
  • “advanced” features supported by high GLSL versions.

This would require the mixing of shaders written in different GLSL versions. Is this possible and supported?

Really, all you should trouble yourself with are:

1: GLSL v1.2
2: GLSL v3.3
3: GLSL v4.0

1.2 is for DX9-class hardware. All OpenGL-capable DX10-class hardware will have up-to-date drivers for GL 3.3 (if not already out, then in the near future), which gives you GLSL v3.3. And DX11-class hardware means you can use GLSL v4.0.

So unless someone has not updated their drivers recently, you can basically ignore GLSL v1.3, 1.4, and 1.5. That being said, at the moment (while there are still older drivers around), using 1.5 instead of 3.3 isn’t a terrible idea.

Still, is it possible to compile and link shaders written in different GLSL versions?

Still, is it possible to compile and link shaders written in different GLSL versions?

Well, because all strings added to a shader object are concatenated together in the order they are given in, all the strings in a shader can only have one version. Specifying a different version is an error.

For linking, things change. You can link different shaders written in different versions. But there are limits. These limits are defined in the various GLSL specifications. In general, you can link shaders into programs for any combination of shader versions 1.4 and above.