Clockworkcoders Tutorials


OpenGL Extensions: Part 2


OpenGL Shading Language Extensions

Now we know enough about extensions to actually use them for our GLSL programs.


Checking Presence of GLSL

To check if the OpenGL Shading Language is present, the extension "GL_ARB_shading_language_100" must be available. If this extension is present, the actual version of the OpenGL Shading Language can be queried with glGetString(GL_SHADING_LANGUAGE_VERSION_ARB). The format of the returned string is:

"major.minor.release vendor_info_string". (with "release" and "vendor_info_string" being optional). Version numbers have 1 or more digits.

Unfortunately this is not possible with the initial version of the OpenGL Shading Language. If the query returns an "GL_INVALID_ENUM" error, then you can assume it is version 1.051 (major=1, minor=0, revision=51).

if (glewIsSupported("GL_ARB_shading_language_100")) 
   int major, minor, revision;
   const GLubyte* sVersion = glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
   if (glGetError() == GL_INVALID_ENUM)
      major = 1; minor = 0; revision=51;
      // parse string sVersion to get major, minor, revision

If "GL_ARB_shading_language_100" is present, the other extensions related to the shading language must be present too: "GL_ARB_shader_objects", "GL_ARB_fragment_shader", and "GL_ARB_vertex_shader".


Go Back to: Extensions Part I

Return to Index