From: Jacek Caban jacek@codeweavers.com
And store version in the context struct. --- dlls/opengl32/unix_wgl.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index caeefeea18e..3b27046b4d9 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -133,6 +133,8 @@ struct context HGLRC share; /* context to be shared with */ int *attribs; /* creation attributes */ DWORD tid; /* thread that the context is current in */ + int major_version; /* major GL version */ + int minor_version; /* minor GL version */ UINT64 debug_callback; /* client pointer */ UINT64 debug_user; /* client pointer */ GLubyte *extensions; /* extension string */ @@ -838,6 +840,19 @@ static BOOL check_extension_support( TEB *teb, const char *extension, const char return FALSE; }
+static void sync_context_version( TEB *teb, struct context *ctx ) +{ + const struct opengl_funcs *funcs = teb->glTable; + const char *version; + + if (ctx->major_version) return; /* already synced */ + + version = (const char *)funcs->p_glGetString( GL_VERSION ); + if (version) parse_gl_version( version, &ctx->major_version, &ctx->minor_version ); + if (!ctx->major_version) ctx->major_version = 1; + TRACE( "context %p version %d.%d\n", ctx, ctx->major_version, ctx->minor_version ); +} + static BOOL get_default_fbo_integer( struct context *ctx, struct opengl_drawable *draw, struct opengl_drawable *read, GLenum pname, GLint *data ) { @@ -1008,24 +1023,14 @@ static char *build_extension_list( TEB *teb ) return available_extensions; }
-static UINT get_context_major_version( TEB *teb ) -{ - struct context *ctx; - - if (!(ctx = get_current_context( teb, NULL, NULL ))) return TRUE; - for (const int *attr = ctx->attribs; attr && attr[0]; attr += 2) - if (attr[0] == WGL_CONTEXT_MAJOR_VERSION_ARB) return attr[1]; - - return 1; -} - /* Check if a GL extension is supported */ -static BOOL is_extension_supported( TEB *teb, const char *extension ) +static BOOL is_extension_supported( TEB *teb, struct context *ctx, const char *extension ) { char *available_extensions = NULL; BOOL ret = FALSE;
- if (get_context_major_version( teb ) < 3) available_extensions = strdup( (const char *)wrap_glGetString( teb, GL_EXTENSIONS ) ); + sync_context_version( teb, ctx ); + if (ctx->major_version < 3) available_extensions = strdup( (const char *)wrap_glGetString( teb, GL_EXTENSIONS ) ); if (!available_extensions) available_extensions = build_extension_list( teb );
if (!available_extensions) ERR( "No OpenGL extensions found, check if your OpenGL setup is correct!\n" ); @@ -1046,11 +1051,12 @@ PROC wrap_wglGetProcAddress( TEB *teb, LPCSTR name ) const struct registry_entry entry = {.name = name}, *found; struct opengl_funcs *funcs = teb->glTable; const void **func_ptr; + struct context *ctx;
/* Without an active context opengl32 doesn't know to what * driver it has to dispatch wglGetProcAddress. */ - if (!get_current_context( teb, NULL, NULL )) + if (!(ctx = get_current_context( teb, NULL, NULL ))) { WARN( "No active WGL context found\n" ); return (void *)-1; @@ -1067,7 +1073,7 @@ PROC wrap_wglGetProcAddress( TEB *teb, LPCSTR name ) { void *driver_func = funcs->p_wglGetProcAddress( name );
- if (!is_extension_supported( teb, found->extension )) + if (!is_extension_supported( teb, ctx, found->extension )) { unsigned int i; static const struct { const char *name, *alt; } alternatives[] =