+GLApi get_gl_api()
+{
+#ifdef GL_ES_VERSION_2_0
+ return OPENGL_ES2;
+#else
+ return OPENGL;
+#endif
+}
+
+inline Version _get_gl_version()
+{
+ string gl_ver = reinterpret_cast<const char *>(glGetString(GL_VERSION));
+ if(!gl_ver.compare(0, 10, "OpenGL ES "))
+ gl_ver.erase(0, 10);
+
+ Version ver(gl_ver.substr(0, gl_ver.find(' ')));
+
+ if(const char *force_ver_ptr = getenv("MSPGL_FORCE_VERSION"))
+ {
+ Version force_ver(force_ver_ptr);
+ if(!(force_ver>=ver))
+ ver = force_ver;
+ }
+
+ return ver;
+}
+
+const Version &get_gl_version()
+{
+ static Version version = _get_gl_version();
+ return version;
+}
+
+inline Version _get_glsl_version()
+{
+ string glsl_ver = reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION));
+ if(!glsl_ver.compare(0, 18, "OpenGL ES GLSL ES "))
+ glsl_ver.erase(0, 18);
+
+ Version ver(glsl_ver.substr(0, glsl_ver.find(' ')));
+
+ if(const char *force_ver_ptr = getenv("MSPGL_FORCE_GLSL_VERSION"))
+ {
+ Version force_ver(force_ver_ptr);
+ if(!(force_ver>=ver))
+ ver = force_ver;
+ }
+
+ return ver;
+}
+
+const Version &get_glsl_version()
+{
+ static Version version = _get_glsl_version();
+ return version;
+}
+
+bool is_version_at_least(unsigned a, unsigned b)