diff --git a/src/opengl.c b/src/opengl.c index 67b5e728..957e4d24 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -32,6 +32,7 @@ #include #include +#include //======================================================================== @@ -42,13 +43,16 @@ static void parseGLVersion(int* major, int* minor, int* rev) { GLuint _major, _minor = 0, _rev = 0; const GLubyte* version; - const GLubyte* ptr; - const char* glesPrefix = "OpenGL ES "; version = glGetString(GL_VERSION); if (!version) return; +#if 0 + // Old version detection code. This doesn't work very well + const GLubyte* ptr; + const char* glesPrefix = "OpenGL ES "; + if (strncmp((const char*) version, glesPrefix, strlen(glesPrefix)) == 0) { // The version string on OpenGL ES has a prefix before the version @@ -76,6 +80,12 @@ static void parseGLVersion(int* major, int* minor, int* rev) _rev = 10 * _rev + (*ptr - '0'); } } +#endif + + // Find version from OpenGL string + for (; version && + !sscanf(version, "%d.%d.%d", &_major, &_minor, &_rev); + ++version); // Store result *major = _major;