From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/unix_wgl.c | 10 ++++++++ dlls/opengl32/wgl.c | 50 ++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 8aa07ac1da6..9f1cb88df75 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -478,6 +478,16 @@ NTSTATUS wgl_wglDeleteContext( void *args ) return STATUS_SUCCESS; }
+NTSTATUS wgl_wglGetProcAddress( void *args ) +{ + struct wglGetProcAddress_params *params = args; + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + /* index where to keep the pointer is in the otherwise unused ret argument */ + void **func_ptr = (void **)&funcs->ext + (UINT_PTR)params->ret; + *func_ptr = funcs->wgl.p_wglGetProcAddress( params->lpszProc ); + return *func_ptr ? STATUS_SUCCESS : STATUS_NOT_FOUND; +} + NTSTATUS wgl_wglMakeCurrent( void *args ) { struct wglMakeCurrent_params *params = args; diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index f4ab29e0356..2e85e639f51 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -621,10 +621,13 @@ static BOOL is_extension_supported( const char *extension ) */ PROC WINAPI wglGetProcAddress( LPCSTR name ) { - struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - void **func_ptr; + struct wglGetProcAddress_params args = + { + .lpszProc = name, + }; struct opengl_extension_desc ext; const struct opengl_extension_desc *ext_ret; + NTSTATUS status;
if (!name) return NULL;
@@ -645,37 +648,28 @@ PROC WINAPI wglGetProcAddress( LPCSTR name ) return NULL; }
- func_ptr = (void **)&funcs->ext + (ext_ret - extension_registry); - if (!*func_ptr) + /* provide the index where to keep the pointer in the otherwise unused ret argument */ + args.ret = (void *)(UINT_PTR)(ext_ret - extension_registry); + if ((status = UNIX_CALL( wglGetProcAddress, &args ))) WARN( "wglGetProcAddres %s returned %#x\n", debugstr_a(name), status ); + else if (!is_extension_supported( ext_ret->extension )) { - void *driver_func = funcs->wgl.p_wglGetProcAddress( name ); - - if (!is_extension_supported(ext_ret->extension)) + unsigned int i; + static const struct { const char *name, *alt; } alternatives[] = { - unsigned int i; - static const struct { const char *name, *alt; } alternatives[] = - { - { "glCopyTexSubImage3DEXT", "glCopyTexSubImage3D" }, /* needed by RuneScape */ - { "glVertexAttribDivisor", "glVertexAttribDivisorARB"}, /* needed by Caffeine */ - }; - - for (i = 0; i < ARRAY_SIZE(alternatives); i++) - { - if (strcmp( name, alternatives[i].name )) continue; - WARN("Extension %s required for %s not supported, trying %s\n", - ext_ret->extension, name, alternatives[i].alt ); - return wglGetProcAddress( alternatives[i].alt ); - } - WARN("Extension %s required for %s not supported\n", ext_ret->extension, name); - return NULL; - } + { "glCopyTexSubImage3DEXT", "glCopyTexSubImage3D" }, /* needed by RuneScape */ + { "glVertexAttribDivisor", "glVertexAttribDivisorARB"}, /* needed by Caffeine */ + };
- if (driver_func == NULL) + for (i = 0; i < ARRAY_SIZE(alternatives); i++) { - WARN("Function %s not supported by driver\n", name); - return NULL; + if (strcmp( name, alternatives[i].name )) continue; + WARN( "Extension %s required for %s not supported, trying %s\n", ext_ret->extension, + name, alternatives[i].alt ); + return wglGetProcAddress( alternatives[i].alt ); } - *func_ptr = driver_func; + + WARN( "Extension %s required for %s not supported\n", ext_ret->extension, name ); + return NULL; }
TRACE("returning %s -> %p\n", name, ext_ret->func);