Commit 6153ced0 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

opengl32: Skip filter_extensions_index() on GL contexts < 3.0.

glGetStringi() is not available before 3.0. We can't trust its function pointer being NULL since the GL implementation is allowed to return anything in this case (*cough* macOS's GL on Metal *cough*). This probably regressed when fd92954d removed the "if (!disabled[0]) return FALSE;" exit from filter_extensions(), although that simply exposed an existing issue.
parent 88e66d07
...@@ -198,13 +198,32 @@ static GLubyte *filter_extensions_list( const char *extensions, const char *disa ...@@ -198,13 +198,32 @@ static GLubyte *filter_extensions_list( const char *extensions, const char *disa
return (GLubyte *)str; return (GLubyte *)str;
} }
static const char *parse_gl_version( const char *gl_version, int *major, int *minor )
{
const char *ptr = gl_version;
*major = atoi( ptr );
if (*major <= 0)
ERR( "Invalid OpenGL major version %d.\n", *major );
while (isdigit( *ptr )) ++ptr;
if (*ptr++ != '.')
ERR( "Invalid OpenGL version string %s.\n", debugstr_a(gl_version) );
*minor = atoi( ptr );
while (isdigit( *ptr )) ++ptr;
return ptr;
}
static GLuint *filter_extensions_index( TEB *teb, const char *disabled ) static GLuint *filter_extensions_index( TEB *teb, const char *disabled )
{ {
const struct opengl_funcs *funcs = teb->glTable; const struct opengl_funcs *funcs = teb->glTable;
const char *ext, *version;
GLuint *disabled_index; GLuint *disabled_index;
GLint extensions_count; GLint extensions_count;
unsigned int i = 0, j; unsigned int i = 0, j;
const char *ext; int major, minor;
if (!funcs->ext.p_glGetStringi) if (!funcs->ext.p_glGetStringi)
{ {
...@@ -213,6 +232,11 @@ static GLuint *filter_extensions_index( TEB *teb, const char *disabled ) ...@@ -213,6 +232,11 @@ static GLuint *filter_extensions_index( TEB *teb, const char *disabled )
if (!funcs->ext.p_glGetStringi) return NULL; if (!funcs->ext.p_glGetStringi) return NULL;
} }
version = (const char *)funcs->gl.p_glGetString( GL_VERSION );
parse_gl_version( version, &major, &minor );
if (major < 3)
return NULL;
funcs->gl.p_glGetIntegerv( GL_NUM_EXTENSIONS, &extensions_count ); funcs->gl.p_glGetIntegerv( GL_NUM_EXTENSIONS, &extensions_count );
disabled_index = malloc( extensions_count * sizeof(*disabled_index) ); disabled_index = malloc( extensions_count * sizeof(*disabled_index) );
if (!disabled_index) return NULL; if (!disabled_index) return NULL;
...@@ -413,24 +437,6 @@ static BOOL check_extension_support( TEB *teb, const char *extension, const char ...@@ -413,24 +437,6 @@ static BOOL check_extension_support( TEB *teb, const char *extension, const char
return FALSE; return FALSE;
} }
static const char *parse_gl_version( const char *gl_version, int *major, int *minor )
{
const char *ptr = gl_version;
*major = atoi( ptr );
if (*major <= 0)
ERR( "Invalid OpenGL major version %d.\n", *major );
while (isdigit( *ptr )) ++ptr;
if (*ptr++ != '.')
ERR( "Invalid OpenGL version string %s.\n", debugstr_a(gl_version) );
*minor = atoi( ptr );
while (isdigit( *ptr )) ++ptr;
return ptr;
}
static void wrap_glGetIntegerv( TEB *teb, GLenum pname, GLint *data ) static void wrap_glGetIntegerv( TEB *teb, GLenum pname, GLint *data )
{ {
const struct opengl_funcs *funcs = teb->glTable; const struct opengl_funcs *funcs = teb->glTable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment