+ // Skip past the first period.
+ char *ptr = strchr(glsl_version_str, '.');
+ assert(ptr != nullptr);
+ ++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.
+ std::istringstream locale_convert(glsl_version_str);
+ locale_convert.imbue(std::locale("C"));
+ double glsl_version;
+ locale_convert >> glsl_version;
+ free(glsl_version_str);
+
+ return glsl_version;
+}
+
+void APIENTRY debug_callback(GLenum source,
+ GLenum type,
+ GLuint id,
+ GLenum severity,
+ GLsizei length,
+ const char *message,
+ const void *userParam)
+#ifdef __GNUC__
+ __attribute__((unused))
+#endif
+;
+
+void APIENTRY debug_callback(GLenum source,
+ GLenum type,
+ GLuint id,
+ GLenum severity,
+ GLsizei length,
+ const char *message,
+ const void *userParam)
+{
+ printf("Debug: %s\n", message);