+double get_glsl_version()
+{
+ char *glsl_version_str = strdup((const char *)glGetString(GL_SHADING_LANGUAGE_VERSION));
+
+ // Skip past the first period.
+ char *ptr = strchr(glsl_version_str, '.');
+ assert(ptr != NULL);
+ ++ptr;
+
+ // Now cut the string off at the next period or space, whatever comes first
+ // (unless the string ends first).
+ while (*ptr && *ptr != '.' && *ptr != ' ') {
+ ++ptr;
+ }
+ *ptr = '\0';
+
+ // Now we have something on the form X.YY. We convert it to a float, and hope
+ // that if it's inexact (e.g. 1.30), atof() will round the same way the
+ // compiler will.
+ float glsl_version = atof(glsl_version_str);
+ free(glsl_version_str);
+
+ return glsl_version;
+}
+