From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 37 +++++++++++++++++++++++++++-------- dlls/wineandroid.drv/opengl.c | 15 +++++--------- dlls/winemac.drv/opengl.c | 26 +++--------------------- dlls/winewayland.drv/opengl.c | 7 +++---- dlls/winex11.drv/opengl.c | 12 +++++------- include/wine/opengl_driver.h | 1 + 6 files changed, 46 insertions(+), 52 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index e8e2eaa1e74..5696216572c 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -311,15 +311,10 @@ static BOOL osmesa_context_destroy( void *private ) return TRUE; }
-static PROC osmesa_get_proc_address( const char *proc ) -{ - return (PROC)pOSMesaGetProcAddress( proc ); -} - -static PROC osmesa_wglGetProcAddress( const char *proc ) +static void *osmesa_get_proc_address( const char *proc ) { if (!strncmp( proc, "wgl", 3 )) return NULL; - return osmesa_get_proc_address( proc ); + return (PROC)pOSMesaGetProcAddress( proc ); }
static BOOL osmesa_wglSwapBuffers( HDC hdc ) @@ -390,12 +385,12 @@ static BOOL osmesa_context_make_current( HDC draw_hdc, HDC read_hdc, void *priva
static struct opengl_funcs osmesa_opengl_funcs = { - .p_wglGetProcAddress = osmesa_wglGetProcAddress, .p_wglSwapBuffers = osmesa_wglSwapBuffers, };
static const struct opengl_driver_funcs osmesa_driver_funcs = { + .p_get_proc_address = osmesa_get_proc_address, .p_init_pixel_formats = osmesa_init_pixel_formats, .p_describe_pixel_format = osmesa_describe_pixel_format, .p_init_wgl_extensions = osmesa_init_wgl_extensions, @@ -416,6 +411,11 @@ static struct opengl_funcs *osmesa_get_wgl_driver( const struct opengl_driver_fu
#endif /* SONAME_LIBOSMESA */
+static void *nulldrv_get_proc_address( const char *name ) +{ + return NULL; +} + static UINT nulldrv_init_pixel_formats( UINT *onscreen_count ) { *onscreen_count = ARRAY_SIZE(pixel_formats); @@ -487,6 +487,7 @@ static BOOL nulldrv_context_make_current( HDC draw_hdc, HDC read_hdc, void *priv
static const struct opengl_driver_funcs nulldrv_funcs = { + .p_get_proc_address = nulldrv_get_proc_address, .p_init_pixel_formats = nulldrv_init_pixel_formats, .p_describe_pixel_format = nulldrv_describe_pixel_format, .p_init_wgl_extensions = nulldrv_init_wgl_extensions, @@ -601,6 +602,24 @@ static BOOL win32u_wglSetPixelFormatWINE( HDC hdc, int format ) return set_dc_pixel_format( hdc, format, TRUE ); }
+static PROC win32u_memory_wglGetProcAddress( const char *name ) +{ + PROC ret; + if (!strncmp( name, "wgl", 3 )) return NULL; + ret = memory_driver_funcs->p_get_proc_address( name ); + TRACE( "%s -> %p\n", debugstr_a(name), ret ); + return ret; +} + +static PROC win32u_display_wglGetProcAddress( const char *name ) +{ + PROC ret; + if (!strncmp( name, "wgl", 3 )) return NULL; + ret = display_driver_funcs->p_get_proc_address( name ); + TRACE( "%s -> %p\n", debugstr_a(name), ret ); + return ret; +} + static void win32u_display_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, UINT *num_formats, UINT *num_onscreen_formats ) { @@ -1164,6 +1183,7 @@ static void memory_funcs_init(void) if (memory_funcs && !(memory_formats_count = memory_driver_funcs->p_init_pixel_formats( &memory_onscreen_count ))) memory_funcs = NULL; if (!memory_funcs) return;
+ memory_funcs->p_wglGetProcAddress = win32u_memory_wglGetProcAddress; memory_funcs->p_get_pixel_formats = win32u_memory_get_pixel_formats;
memory_funcs->p_wglGetPixelFormat = win32u_wglGetPixelFormat; @@ -1189,6 +1209,7 @@ static void display_funcs_init(void) if (display_funcs && !(display_formats_count = display_driver_funcs->p_init_pixel_formats( &display_onscreen_count ))) display_funcs = NULL; if (!display_funcs) return;
+ display_funcs->p_wglGetProcAddress = win32u_display_wglGetProcAddress; display_funcs->p_get_pixel_formats = win32u_display_get_pixel_formats;
strcpy( wgl_extensions, display_driver_funcs->p_init_wgl_extensions() ); diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 6a83b9b93ca..c20ac95a936 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -411,16 +411,11 @@ static BOOL android_context_destroy( void *private ) return TRUE; }
-/*********************************************************************** - * android_wglGetProcAddress - */ -static PROC android_wglGetProcAddress( LPCSTR name ) +static void *android_get_proc_address( const char *name ) { - PROC ret; - if (!strncmp( name, "wgl", 3 )) return NULL; - ret = (PROC)p_eglGetProcAddress( name ); - TRACE( "%s -> %p\n", name, ret ); - return ret; + void *ptr; + if ((ptr = dlsym( opengl_handle, name ))) return ptr; + return p_eglGetProcAddress( name ); }
static BOOL android_context_share( void *org, void *dest ) @@ -828,6 +823,7 @@ static UINT android_init_pixel_formats( UINT *onscreen_count )
static const struct opengl_driver_funcs android_driver_funcs = { + .p_get_proc_address = android_get_proc_address, .p_init_pixel_formats = android_init_pixel_formats, .p_describe_pixel_format = android_describe_pixel_format, .p_init_wgl_extensions = android_init_wgl_extensions, @@ -907,7 +903,6 @@ ALL_GL_FUNCS
static struct opengl_funcs egl_funcs = { - .p_wglGetProcAddress = android_wglGetProcAddress, .p_wglSwapBuffers = android_wglSwapBuffers, #define USE_GL_FUNC(name) .p_##name = (void *)glstub_##name, ALL_GL_FUNCS diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index eedfa0219b2..9aa50b69b78 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -3186,29 +3186,9 @@ static BOOL macdrv_context_share(void *src_private, void *dst_private) return TRUE; }
-/*********************************************************************** - * macdrv_wglGetProcAddress - */ -static PROC macdrv_wglGetProcAddress(const char *proc) +static void *macdrv_get_proc_address(const char *name) { - void *ret; - - if (!strncmp(proc, "wgl", 3)) return NULL; - ret = dlsym(opengl_handle, proc); - if (ret) - { - if (TRACE_ON(wgl)) - { - Dl_info info; - if (dladdr(ret, &info)) - TRACE("%s -> %s from %s\n", proc, info.dli_sname, info.dli_fname); - else - TRACE("%s -> %p (no library info)\n", proc, ret); - } - } - else - WARN("failed to find proc %s\n", debugstr_a(proc)); - return ret; + return dlsym(opengl_handle, name); }
/********************************************************************** @@ -3280,6 +3260,7 @@ static BOOL macdrv_wglSwapBuffers(HDC hdc)
static const struct opengl_driver_funcs macdrv_driver_funcs = { + .p_get_proc_address = macdrv_get_proc_address, .p_init_pixel_formats = macdrv_init_pixel_formats, .p_describe_pixel_format = macdrv_describe_pixel_format, .p_init_wgl_extensions = macdrv_init_wgl_extensions, @@ -3297,6 +3278,5 @@ static const struct opengl_driver_funcs macdrv_driver_funcs =
static struct opengl_funcs opengl_funcs = { - .p_wglGetProcAddress = macdrv_wglGetProcAddress, .p_wglSwapBuffers = macdrv_wglSwapBuffers, }; diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 424fc65a8ab..758b483d8bc 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -523,10 +523,9 @@ static BOOL wayland_context_destroy(void *private) return TRUE; }
-static PROC wayland_wglGetProcAddress(LPCSTR name) +static void *wayland_get_proc_address(const char *name) { - if (!strncmp(name, "wgl", 3)) return NULL; - return (PROC)p_eglGetProcAddress(name); + return p_eglGetProcAddress(name); }
static int wayland_wglGetSwapIntervalEXT(void) @@ -935,6 +934,7 @@ static UINT wayland_init_pixel_formats(UINT *onscreen_count)
static const struct opengl_driver_funcs wayland_driver_funcs = { + .p_get_proc_address = wayland_get_proc_address, .p_init_pixel_formats = wayland_init_pixel_formats, .p_describe_pixel_format = wayland_describe_pixel_format, .p_init_wgl_extensions = wayland_init_wgl_extensions, @@ -1055,7 +1055,6 @@ err:
static struct opengl_funcs opengl_funcs = { - .p_wglGetProcAddress = wayland_wglGetProcAddress, .p_wglSwapBuffers = wayland_wglSwapBuffers, };
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 9dcbb25e4e4..6f5b86ce19b 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1567,13 +1567,11 @@ static BOOL x11drv_context_destroy(void *private) return TRUE; }
-/*********************************************************************** - * glxdrv_wglGetProcAddress - */ -static PROC glxdrv_wglGetProcAddress(LPCSTR lpszProc) +static void *x11drv_get_proc_address( const char *name ) { - if (!strncmp(lpszProc, "wgl", 3)) return NULL; - return pglXGetProcAddressARB((const GLubyte*)lpszProc); + void *ptr; + if ((ptr = dlsym( opengl_handle, name ))) return ptr; + return pglXGetProcAddressARB( (const GLubyte *)name ); }
static void set_context_drawables( struct x11drv_context *ctx, struct gl_drawable *draw, @@ -2203,6 +2201,7 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc )
static const struct opengl_driver_funcs x11drv_driver_funcs = { + .p_get_proc_address = x11drv_get_proc_address, .p_init_pixel_formats = x11drv_init_pixel_formats, .p_describe_pixel_format = x11drv_describe_pixel_format, .p_init_wgl_extensions = x11drv_init_wgl_extensions, @@ -2220,7 +2219,6 @@ static const struct opengl_driver_funcs x11drv_driver_funcs =
static struct opengl_funcs opengl_funcs = { - .p_wglGetProcAddress = glxdrv_wglGetProcAddress, .p_wglSwapBuffers = glxdrv_wglSwapBuffers, };
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 2a760e98020..f1f7da379e8 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -113,6 +113,7 @@ struct opengl_funcs /* interface between win32u and the user drivers */ struct opengl_driver_funcs { + void *(*p_get_proc_address)(const char *); UINT (*p_init_pixel_formats)(UINT*); BOOL (*p_describe_pixel_format)(int,struct wgl_pixel_format*); const char *(*p_init_wgl_extensions)(void);