Skip to content

Commit

Permalink
Support encoding minor versions bigger than 10
Browse files Browse the repository at this point in the history
The GL version minor numbers haven't hit 10, yet, but if they do we're
going to get non-sensical encoded versions when calling
epoxy_gl_version(), like we're getting right now, with the GLSL version
numbers.

If the minor number is larger than the multiplication factor used for
the major number, we should bump up the factor to the next order of
magnitude.
  • Loading branch information
ebassi committed Feb 24, 2018
1 parent 1489c20 commit e1ffd32
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/dispatch_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static int
epoxy_internal_gl_version(GLenum version_string, int error_version)
{
const char *version = (const char *)glGetString(version_string);
GLint major, minor;
GLint major, minor, factor;
int scanf_count;

if (!version)
Expand All @@ -412,7 +412,13 @@ epoxy_internal_gl_version(GLenum version_string, int error_version)
version);
exit(1);
}
return 10 * major + minor;

if (minor >= 10)
factor = 100;
else
factor = 10;

return factor * major + minor;
}

/**
Expand Down Expand Up @@ -452,7 +458,7 @@ epoxy_conservative_gl_version(void)
*
* ```
*
* version = major * 10 + minor
* version = major * 100 + minor
*
* ```
*
Expand Down

0 comments on commit e1ffd32

Please sign in to comment.