Patch for opengl32.dll.so

Bertrand Coconnier bcoconni at club-internet.fr
Wed Nov 1 10:20:59 CST 2006


Hi,

The last release of Wine 0.9.24 contains an error in the code of opengl32.dll.so 
under X11 : Wine tries to get the address of "wglGetIntegerv" (line 608 of 
dlls/opengl32/wgl.c) before the extensions of WGL have actually been loaded 
(i.e. before X11DRV_WineGL_LoadExtensions() is called). The reading of the 
wglGetIntegerv address fails and afterwards, whenever internal_glGetIntegerv() 
is called, wine_wgl.p_wglGetIntegerv is NULL and a Fatal Exception is raised.

This behaviour is obtained when trying to launch World of Warcraft in OpenGL 
mode. Of course, the bug does not occur if WoW is launched with DirectX.

Attached is the patch that fixes this bug. It prevents Wine to trying to get the 
address of wglGetIntegerv in the function process_attach() and tries instead to 
get the address in internal_glGetIntegerv().

The patch may look a bit hackish but since wine_wgl.p_wglGetIntegerv seems not 
to be used anywhere else, it seems to me that wine_wgl.p_wglGetIntegerv can be 
loaded "just in time" when, hopefully, the WGL extensions have been loaded 
themselves.

Regards,

Bertrand Coconnier.
-------------- next part --------------
diff --git a/ChangeLog b/ChangeLog
index 3615646..4a2838e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-11-01 Bertrand Coconnier <bcoconni at club-internet.fr>
+	* dlls/opengl32/wgl.c:
+	opengl32: Fix wglGetIntegerv initialization which may have failed when it is called
+
 2006-10-27  Alexandre Julliard <julliard at winehq.org>
 
 	* dlls/wined3d/directx.c:
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 5912adf..f83418f 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -566,7 +566,11 @@ void internal_glGetIntegerv(GLenum pname
   TRACE("pname: 0x%x, params %p\n", pname, params);
   glGetIntegerv(pname, params);
   /* A few parameters like GL_DEPTH_BITS differ between WGL and GLX, the wglGetIntegerv helper function handles those */
-  wine_wgl.p_wglGetIntegerv(pname, params);
+  if (!wine_wgl.p_wglGetIntegerv)
+    wine_wgl.p_wglGetIntegerv = (void *)wine_wgl.p_wglGetProcAddress("wglGetIntegerv");
+
+  if (wine_wgl.p_wglGetIntegerv)
+    wine_wgl.p_wglGetIntegerv(pname, params);
 }
 
 
@@ -604,9 +608,6 @@ static BOOL process_attach(void)
 
   wine_wgl.p_wglGetProcAddress = (void *)GetProcAddress(mod_gdi32, "wglGetProcAddress");
 
-  /* Interal WGL function */
-  wine_wgl.p_wglGetIntegerv = (void *)wine_wgl.p_wglGetProcAddress("wglGetIntegerv");
-
   hdc = GetDC(0);
   default_display = get_display( hdc );
   ReleaseDC( 0, hdc );


More information about the wine-patches mailing list