mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-06 04:40:29 +01:00
gl: Correctly extract GL version from OpenGL ES version strings
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>
This commit is contained in:
parent
b1c96f1852
commit
f1eef40c2a
1 changed files with 5 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue