diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index 5b959e7ac1d..a751c727702 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -198,6 +198,7 @@ static struct graphics_driver *create_driver( HMODULE module ) /* OpenGL32 */ GET_FUNC(wglCreateContext); GET_FUNC(wglDeleteContext); + GET_FUNC(wglGetProcAddress); GET_FUNC(wglMakeCurrent); GET_FUNC(wglShareLists); GET_FUNC(wglUseFontBitmapsA); diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec index cf08bdfa2c8..cea9a5cf5e0 100644 --- a/dlls/gdi32/gdi32.spec +++ b/dlls/gdi32/gdi32.spec @@ -502,6 +502,7 @@ @ stdcall wglDeleteContext(long) @ stdcall wglGetCurrentContext() @ stdcall wglGetCurrentDC() +@ stdcall -private wglGetProcAddress(str) @ stdcall wglMakeCurrent(long long) @ stdcall wglShareLists(long long) @ stdcall wglUseFontBitmapsA(long long long long) diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 725ed8cac7b..d1731511a13 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -186,6 +186,7 @@ typedef struct tagDC_FUNCS /* OpenGL32 */ HGLRC (*pwglCreateContext)(PHYSDEV); BOOL (*pwglDeleteContext)(HGLRC); + PROC (*pwglGetProcAddress)(LPCSTR); BOOL (*pwglMakeCurrent)(PHYSDEV, HGLRC); BOOL (*pwglShareLists)(HGLRC hglrc1, HGLRC hglrc2); BOOL (*pwglUseFontBitmapsA)(PHYSDEV, DWORD, DWORD, DWORD); diff --git a/dlls/gdi32/opengl.c b/dlls/gdi32/opengl.c index 6d970252b13..2be485e26e7 100644 --- a/dlls/gdi32/opengl.c +++ b/dlls/gdi32/opengl.c @@ -221,3 +221,28 @@ BOOL WINAPI wglUseFontBitmapsW(HDC hdc, DWORD first, DWORD count, DWORD listBase GDI_ReleaseObj( hdc); return ret; } + +/*********************************************************************** + * Internal wglGetProcAddress for retrieving WGL extensions + */ +PROC WINAPI wglGetProcAddress(LPCSTR func) +{ + PROC ret = NULL; + DC * dc = NULL; + + if(!func) + return NULL; + + TRACE("func: '%p'\n", func); + + /* Retrieve the global hDC to get access to the driver. */ + dc = OPENGL_GetDefaultDC(); + if (!dc) return FALSE; + + if (!dc->funcs->pwglGetProcAddress) FIXME(" :stub\n"); + else ret = dc->funcs->pwglGetProcAddress(func); + + GDI_ReleaseObj(default_hdc); + + return ret; +} diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 3a4f5492528..5912adf0614 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -79,8 +79,6 @@ static Display *default_display; /* display to use for default context */ static HMODULE opengl32_handle; -static void* (*p_glXGetProcAddressARB)(const GLubyte *); - static char internal_gl_disabled_extensions[512]; static char* internal_gl_extensions = NULL; @@ -193,11 +191,6 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) { return local_func; } - if (p_glXGetProcAddressARB == NULL) { - ERR("Warning : dynamic GL extension loading not supported by native GL library.\n"); - return NULL; - } - /* After that, search in the thunks to find the real name of the extension */ ext.name = lpszProc; ext_ret = (const OpenGL_extension *) bsearch(&ext, extension_registry, @@ -205,13 +198,11 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) { /* If nothing was found, we are looking for a WGL extension */ if (ext_ret == NULL) { + WARN("Extension '%s' not defined in opengl32.dll's function table!\n", lpszProc); return wine_wgl.p_wglGetProcAddress(lpszProc); } else { /* We are looking for an OpenGL extension */ - const char *glx_name = ext_ret->glx_name ? ext_ret->glx_name : ext_ret->name; - ENTER_GL(); - local_func = p_glXGetProcAddressARB( (const GLubyte*)glx_name); - LEAVE_GL(); - + local_func = wine_wgl.p_wglGetProcAddress(ext_ret->name); + /* After that, look at the extensions defined in the Linux OpenGL library */ if (local_func == NULL) { char buf[256]; @@ -224,15 +215,15 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) { OpenGL drivers (moreover, it is only useful for old 1.0 apps that query the glBindTextureEXT extension). */ - memcpy(buf, glx_name, strlen(glx_name) - 3); - buf[strlen(glx_name) - 3] = '\0'; + memcpy(buf, ext_ret->name, strlen(ext_ret->name) - 3); + buf[strlen(ext_ret->name) - 3] = '\0'; TRACE(" extension not found in the Linux OpenGL library, checking against libGL bug with %s..\n", buf); ret = GetProcAddress(opengl32_handle, buf); if (ret != NULL) { - TRACE(" found function in main OpenGL library (%p) !\n", ret); + TRACE(" found function in main OpenGL library (%p) !\n", ret); } else { - WARN("Did not find function %s (%s) in your OpenGL library !\n", lpszProc, glx_name); + WARN("Did not find function %s (%s) in your OpenGL library !\n", lpszProc, ext_ret->name); } return ret; @@ -598,24 +589,23 @@ static BOOL process_attach(void) XVisualInfo *vis = NULL; Window root = (Window)GetPropA( GetDesktopWindow(), "__wine_x11_whole_window" ); HMODULE mod = GetModuleHandleA( "winex11.drv" ); - void *opengl_handle; + HMODULE mod_gdi32 = GetModuleHandleA( "gdi32.dll" ); DWORD size = sizeof(internal_gl_disabled_extensions); HKEY hkey = 0; - if (!root || !mod) + if (!root || !mod || !mod_gdi32) { - ERR("X11DRV not loaded. Cannot create default context.\n"); + ERR("X11DRV or GDI32 not loaded. Cannot create default context.\n"); return FALSE; } wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" ); wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); - /* Load WGL function pointers from winex11.drv */ - wine_wgl.p_wglGetProcAddress = (void *)GetProcAddress(mod, "wglGetProcAddress"); + wine_wgl.p_wglGetProcAddress = (void *)GetProcAddress(mod_gdi32, "wglGetProcAddress"); /* Interal WGL function */ - wine_wgl.p_wglGetIntegerv = (void *)GetProcAddress(mod, "wglGetIntegerv"); + wine_wgl.p_wglGetIntegerv = (void *)wine_wgl.p_wglGetProcAddress("wglGetIntegerv"); hdc = GetDC(0); default_display = get_display( hdc ); @@ -651,14 +641,6 @@ static BOOL process_attach(void) XFree(vis); LEAVE_GL(); - opengl_handle = wine_dlopen(SONAME_LIBGL, RTLD_NOW|RTLD_GLOBAL, NULL, 0); - if (opengl_handle != NULL) { - p_glXGetProcAddressARB = wine_dlsym(opengl_handle, "glXGetProcAddressARB", NULL, 0); - wine_dlclose(opengl_handle, NULL, 0); - if (p_glXGetProcAddressARB == NULL) - TRACE("could not find glXGetProcAddressARB in libGL.\n"); - } - internal_gl_disabled_extensions[0] = 0; if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\OpenGL", &hkey)) { if (!RegQueryValueExA( hkey, "DisabledExtensions", 0, NULL, (LPBYTE)internal_gl_disabled_extensions, &size)) { diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index bdd08c43d36..046c57b956b 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1299,19 +1299,24 @@ PROC X11DRV_wglGetProcAddress(LPCSTR lpszProc) if (padding < 0) padding = 0; - TRACE("('%s'):%*s", lpszProc, padding, " "); - for (i = 0; i < WineGLExtensionListSize; ++i) { - ext = WineGLExtensionList[i]; - for (j = 0; ext->extEntryPoints[j].funcName; ++j) { - if (strcmp(ext->extEntryPoints[j].funcName, lpszProc) == 0) { - TRACE("(%p) - WineGL\n", ext->extEntryPoints[j].funcAddress); - return ext->extEntryPoints[j].funcAddress; + /* Check the table of WGL extensions to see if we need to return a WGL extension + * or a function pointer to a native OpenGL function. */ + if(strncmp(lpszProc, "wgl", 3) != 0) { + return pglXGetProcAddressARB((GLubyte*)lpszProc); + } else { + TRACE("('%s'):%*s", lpszProc, padding, " "); + for (i = 0; i < WineGLExtensionListSize; ++i) { + ext = WineGLExtensionList[i]; + for (j = 0; ext->extEntryPoints[j].funcName; ++j) { + if (strcmp(ext->extEntryPoints[j].funcName, lpszProc) == 0) { + TRACE("(%p) - WineGL\n", ext->extEntryPoints[j].funcAddress); + return ext->extEntryPoints[j].funcAddress; + } } } } ERR("(%s) - not found\n", lpszProc); - return NULL; } @@ -2457,6 +2462,15 @@ static BOOL register_extension(const WineGLExtension * ext) return TRUE; } +static const WineGLExtension WGL_internal_functions = +{ + "", + { + { "wglGetIntegerv", X11DRV_wglGetIntegerv }, + } +}; + + static const WineGLExtension WGL_ARB_extensions_string = { "WGL_ARB_extensions_string", @@ -2536,6 +2550,9 @@ static void X11DRV_WineGL_LoadExtensions(void) { WineGLInfo.wglExtensions[0] = 0; + /* Load Wine internal functions */ + register_extension(&WGL_internal_functions); + /* ARB Extensions */ register_extension(&WGL_ARB_extensions_string); @@ -2795,11 +2812,6 @@ BOOL WINAPI X11DRV_wglUseFontBitmapsW(HDC hdc, DWORD first, DWORD count, DWORD l return FALSE; } -/* WGL helper function which handles differences in glGetIntegerv from WGL and GLX */ -void X11DRV_wglGetIntegerv(int pname, int* params) { - ERR_(opengl)("No OpenGL support compiled in.\n"); -} - XVisualInfo *X11DRV_setup_opengl_visual( Display *display ) { return NULL; diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec index a0fef447b91..56c2c1aa444 100644 --- a/dlls/winex11.drv/winex11.drv.spec +++ b/dlls/winex11.drv/winex11.drv.spec @@ -133,7 +133,6 @@ # OpenGL @ cdecl wglCreateContext(long) X11DRV_wglCreateContext @ cdecl wglDeleteContext(long) X11DRV_wglDeleteContext -@ cdecl wglGetIntegerv(long ptr) X11DRV_wglGetIntegerv @ cdecl wglGetProcAddress(ptr) X11DRV_wglGetProcAddress @ cdecl wglMakeCurrent(long long) X11DRV_wglMakeCurrent @ cdecl wglShareLists(long long) X11DRV_wglShareLists