From: Rémi Bernon rbernon@codeweavers.com
--- configure.ac | 2 +- dlls/win32u/opengl.c | 19 ++++++++++++++++ dlls/wineandroid.drv/opengl.c | 10 ++------- dlls/winemac.drv/opengl.c | 26 ++++++++-------------- dlls/winex11.drv/opengl.c | 42 +++++++++++++++-------------------- include/wine/opengl_driver.h | 1 + 6 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/configure.ac b/configure.ac index 056d18b378b..3898fbba8fe 100644 --- a/configure.ac +++ b/configure.ac @@ -988,7 +988,7 @@ case $host_os in WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],[WINELOADER_LDFLAGS="-Wl,--export-dynamic"]) WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7d400000"
- WINE_CHECK_SONAME(GLESv2,glFlush) + WINE_CHECK_SONAME(GLESv2,glFlush,[AC_DEFINE_UNQUOTED(SONAME_LIBGL,["$ac_cv_lib_soname_GLESv2"])])
if test "x$exec_prefix" = xNONE then diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 561d09f96f2..ecd95c8c553 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1623,6 +1623,24 @@ static int win32u_wglGetSwapIntervalEXT(void) return interval; }
+static BOOL opengl_init( struct opengl_funcs *funcs ) +{ +#if defined(__APPLE__) + funcs->opengl_handle = dlopen( "/System/Library/Frameworks/OpenGL.framework/OpenGL", + RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD ); + if (!funcs->opengl_handle) WARN( "Failed to load OpenGL: %s\n", dlerror() ); +#endif +#if defined(SONAME_LIBGL) + if (!funcs->opengl_handle) + { + funcs->opengl_handle = dlopen( SONAME_LIBGL, RTLD_NOW | RTLD_GLOBAL ); + if (!funcs->opengl_handle) WARN( "Failed to load %s: %s\n", SONAME_LIBGL, dlerror() ); + } +#endif + + return !!funcs->opengl_handle; +} + static void init_opengl_funcs( struct opengl_funcs *funcs, const struct opengl_driver_funcs *driver_funcs ) { #define USE_GL_FUNC(func) \ @@ -1662,6 +1680,7 @@ static void display_funcs_init(void) { UINT status;
+ if (opengl_init( &display_funcs )) TRACE( "Initialized OpenGL library\n" ); if (egl_init( &display_driver_funcs )) TRACE( "Initialized EGL library\n" );
if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &display_driver_funcs ))) diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 60cdd419f62..d861c158208 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -77,7 +77,6 @@ struct gl_drawable int swap_interval; };
-static void *opengl_handle; static struct list gl_contexts = LIST_INIT( gl_contexts ); static struct list gl_drawables = LIST_INIT( gl_drawables );
@@ -322,7 +321,7 @@ static EGLenum android_init_egl_platform( const struct egl_platform *platform, E static void *android_get_proc_address( const char *name ) { void *ptr; - if ((ptr = dlsym( opengl_handle, name ))) return ptr; + if ((ptr = dlsym( funcs->opengl_handle, name ))) return ptr; return funcs->p_eglGetProcAddress( name ); }
@@ -399,12 +398,7 @@ UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_OPENGL_DRIVER_VERSION ); return STATUS_INVALID_PARAMETER; } - if (!opengl_funcs->egl_handle) return STATUS_NOT_SUPPORTED; - if (!(opengl_handle = dlopen( SONAME_LIBGLESV2, RTLD_NOW|RTLD_GLOBAL ))) - { - ERR( "failed to load %s: %s\n", SONAME_LIBGLESV2, dlerror() ); - return STATUS_NOT_SUPPORTED; - } + if (!opengl_funcs->egl_handle || !opengl_funcs->opengl_handle) return STATUS_NOT_SUPPORTED; funcs = opengl_funcs;
android_driver_funcs.p_init_pixel_formats = (*driver_funcs)->p_init_pixel_formats; diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index bf41fd3fe99..1909cee8c27 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -86,7 +86,6 @@ static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER; static CFMutableDictionaryRef dc_pbuffers; static pthread_mutex_t dc_pbuffers_mutex = PTHREAD_MUTEX_INITIALIZER;
-static void *opengl_handle; static const struct opengl_funcs *funcs; static const struct opengl_driver_funcs macdrv_driver_funcs;
@@ -2744,20 +2743,19 @@ UINT macdrv_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, co return STATUS_NOT_SUPPORTED; }
- opengl_handle = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY|RTLD_LOCAL|RTLD_NOLOAD); - if (!opengl_handle) + if (!funcs->opengl_handle) { ERR("Failed to load OpenGL: %s\n", dlerror()); ERR("OpenGL support is disabled.\n"); return STATUS_NOT_SUPPORTED; }
-#define LOAD_FUNCPTR(func) \ - if (!(p##func = dlsym(opengl_handle, #func))) \ - { \ - ERR( "%s not found in libGL, disabling OpenGL.\n", #func ); \ - goto failed; \ - } +#define LOAD_FUNCPTR(func) \ + if (!(p##func = dlsym(funcs->opengl_handle, #func))) \ + { \ + ERR("%s not found in libGL, disabling OpenGL.\n", #func); \ + return STATUS_NOT_SUPPORTED; \ + } LOAD_FUNCPTR(glCopyPixels); LOAD_FUNCPTR(glGetIntegerv); LOAD_FUNCPTR(glGetString); @@ -2765,8 +2763,7 @@ UINT macdrv_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, co LOAD_FUNCPTR(glViewport); LOAD_FUNCPTR(glCopyColorTable);
- if (!init_gl_info()) - goto failed; + if (!init_gl_info()) return STATUS_NOT_SUPPORTED;
if (gluCheckExtension((GLubyte*)"GL_APPLE_flush_render", (GLubyte*)gl_info.glExtensions)) LOAD_FUNCPTR(glFlushRenderAPPLE); @@ -2774,11 +2771,6 @@ UINT macdrv_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, co
*driver_funcs = &macdrv_driver_funcs; return STATUS_SUCCESS; - -failed: - dlclose(opengl_handle); - opengl_handle = NULL; - return STATUS_NOT_SUPPORTED; }
@@ -2920,7 +2912,7 @@ static void *macdrv_get_proc_address(const char *name)
/* redirect some OpenGL extension functions */ if (!strcmp(name, "glCopyColorTable")) return macdrv_glCopyColorTable; - return dlsym(opengl_handle, name); + return dlsym(funcs->opengl_handle, name); }
static BOOL macdrv_swap_buffers(void *private, HWND hwnd, HDC hdc, int interval) diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index b3c032db8f0..369b34824c4 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -348,7 +348,6 @@ static INT64 (*pglXSwapBuffersMscOML)( Display *dpy, GLXDrawable drawable, /* Standard OpenGL */ static const GLubyte *(*pglGetString)(GLenum name);
-static void *opengl_handle; static const struct opengl_funcs *funcs; static const struct opengl_driver_funcs x11drv_driver_funcs;
@@ -508,8 +507,7 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c
/* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and include all dependencies */ - opengl_handle = dlopen( SONAME_LIBGL, RTLD_NOW | RTLD_GLOBAL ); - if (opengl_handle == NULL) + if (!funcs->opengl_handle) { ERR( "Failed to load libGL: %s\n", dlerror() ); ERR( "OpenGL support is disabled.\n"); @@ -517,26 +515,27 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c }
/* redirect some standard OpenGL functions */ -#define LOAD_FUNCPTR(func) \ - if (!(p##func = dlsym( opengl_handle, #func ))) \ - { \ - ERR( "%s not found in libGL, disabling OpenGL.\n", #func ); \ - goto failed; \ - } +#define LOAD_FUNCPTR( func ) \ + if (!(p##func = dlsym( funcs->opengl_handle, #func ))) \ + { \ + ERR( "%s not found in libGL, disabling OpenGL.\n", #func ); \ + return STATUS_NOT_SUPPORTED; \ + } LOAD_FUNCPTR( glGetString ); #undef LOAD_FUNCPTR
- pglXGetProcAddressARB = dlsym(opengl_handle, "glXGetProcAddressARB"); + pglXGetProcAddressARB = dlsym( funcs->opengl_handle, "glXGetProcAddressARB" ); if (pglXGetProcAddressARB == NULL) { ERR("Could not find glXGetProcAddressARB in libGL, disabling OpenGL.\n"); - goto failed; + return STATUS_NOT_SUPPORTED; }
-#define LOAD_FUNCPTR(f) do if((p##f = (void*)pglXGetProcAddressARB((const unsigned char*)#f)) == NULL) \ - { \ - ERR( "%s not found in libGL, disabling OpenGL.\n", #f ); \ - goto failed; \ - } while(0) +#define LOAD_FUNCPTR( f ) \ + if (!(p##f = (void *)pglXGetProcAddressARB( (const GLubyte *)#f ))) \ + { \ + ERR( "%s not found in libGL, disabling OpenGL.\n", #f ); \ + return STATUS_NOT_SUPPORTED; \ + }
/* GLX 1.0 */ LOAD_FUNCPTR(glXChooseVisual); @@ -584,14 +583,14 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c LOAD_FUNCPTR(glXFreeMemoryNV); #undef LOAD_FUNCPTR
- if(!X11DRV_WineGL_InitOpenglInfo()) goto failed; + if (!X11DRV_WineGL_InitOpenglInfo()) return STATUS_NOT_SUPPORTED;
if (XQueryExtension( gdi_display, "GLX", &glx_opcode, &event_base, &error_base )) { TRACE("GLX is up and running error_base = %d\n", error_base); } else { ERR( "GLX extension is missing, disabling OpenGL.\n" ); - goto failed; + return STATUS_NOT_SUPPORTED; } gl_hwnd_context = XUniqueContext(); gl_pbuffer_context = XUniqueContext(); @@ -674,11 +673,6 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c
*driver_funcs = &x11drv_driver_funcs; return STATUS_SUCCESS; - -failed: - dlclose(opengl_handle); - opengl_handle = NULL; - return STATUS_NOT_SUPPORTED; }
static const char *debugstr_fbconfig( GLXFBConfig fbconfig ) @@ -1508,7 +1502,7 @@ static BOOL x11drv_context_destroy(void *private) static void *x11drv_get_proc_address( const char *name ) { void *ptr; - if ((ptr = dlsym( opengl_handle, name ))) return ptr; + if ((ptr = dlsym( funcs->opengl_handle, name ))) return ptr; return pglXGetProcAddressARB( (const GLubyte *)name ); }
diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index ed441fdb932..29e1085c30c 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -112,6 +112,7 @@ struct opengl_funcs #undef USE_GL_FUNC
void *egl_handle; + void *opengl_handle; };
struct egl_platform