diff mbox

[01/21] gl: Correctly extract GL version from OpenGL ES version strings

Message ID 1311602208-5973-1-git-send-email-alexandros.frantzis@linaro.org
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org July 25, 2011, 1:56 p.m. UTC
From: Alexandros Frantzis <alexandros.frantzis@linaro.org>

The GL version string returned by glGetString() for GLES doesn't have the
version number at the beginning of the string.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 src/cairo-gl-info.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/src/cairo-gl-info.c b/src/cairo-gl-info.c
index 5b4190e..168d194 100644
--- a/src/cairo-gl-info.c
+++ b/src/cairo-gl-info.c
@@ -38,13 +38,17 @@  _cairo_gl_get_version (void)
     int major, minor;
     const char *version = (const char *) glGetString (GL_VERSION);
     const char *dot = version == NULL ? NULL : strchr (version, '.');
+    const char *major_start = dot;
 
     /* Sanity check */
     if (dot == NULL || dot == version || *(dot + 1) == '\0') {
 	major = 0;
 	minor = 0;
     } else {
-	major = strtol (version, NULL, 10);
+	/* Find the start of the major version in the string */
+	while (major_start > version && *major_start != ' ')
+	    --major_start;
+	major = strtol (major_start, NULL, 10);
 	minor = strtol (dot + 1, NULL, 10);
     }