[PATCH] WineD3D: Always load glFinish and glFlush from =

Stefan Doesinger stefan at codeweavers.com
Wed Jul 30 10:53:33 CDT 2008

winex11.drv hooks those functions to update the window when=0A=
rendering to a child window on a call to glFlush and glFinish. This=0A=
is needed to make front buffer drawing work correctly in d3d=0A=
 dlls/wined3d/directx.c    |   14 +++++++++++++-=0A=
 include/wine/wined3d_gl.h |   10 ++++++----=0A=
 2 files changed, 19 insertions(+), 5 deletions(-)=0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index 8ec7397..c28082f 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -3971,7 +3971,7 @@ void fillGLAttribFuncs(WineD3D_GL_Info *gl_info) {=0A=
 #define PUSH1(att)        attribs[nAttribs++] =3D (att);=0A=
 BOOL InitAdapters(void) {=0A=
-    static HMODULE mod_gl;=0A=
+    static HMODULE mod_gl, mod_win32gl;=0A=
     BOOL ret;=0A=
     int ps_selected_mode, vs_selected_mode;=0A=
@@ -3990,10 +3990,16 @@ BOOL InitAdapters(void) {=0A=
             ERR("Can't load opengl32.dll!\n");=0A=
             goto nogl_adapter;=0A=
+        mod_win32gl =3D mod_gl;=0A=
 #define USE_GL_FUNC(pfn) pfn =3D (void*)pwglGetProcAddress(#pfn);=0A=
         /* To bypass the opengl32 thunks load wglGetProcAddress from =
gdi32 (glXGetProcAddress wrapper) instead of opengl32's */=0A=
         mod_gl =3D GetModuleHandleA("gdi32.dll");=0A=
+        mod_win32gl =3D LoadLibraryA("opengl32.dll");=0A=
+        if(!mod_win32gl) {=0A=
+            ERR("Can't load opengl32.dll!\n");=0A=
+            goto nogl_adapter;=0A=
+        }=0A=
@@ -4011,6 +4017,12 @@ BOOL InitAdapters(void) {=0A=
 #undef USE_GL_FUNC=0A=
+    /* Load glFinish and glFlush from opengl32.dll even if we're not =
using WIN32 opengl=0A=
+     * otherwise because we have to use winex11.drv's override=0A=
+     */=0A=
+    glFinish =3D (void*)GetProcAddress(mod_win32gl, "glFinish");=0A=
+    glFlush =3D (void*)GetProcAddress(mod_win32gl, "glFlush");=0A=
     /* For now only one default adapter */=0A=
         int iPixelFormat;=0A=
diff --git a/include/wine/wined3d_gl.h b/include/wine/wined3d_gl.h=0A=
index ac4967d..1b27d98 100644=0A=
--- a/include/wine/wined3d_gl.h=0A=
+++ b/include/wine/wined3d_gl.h=0A=
@@ -890,8 +890,6 @@ void (WINE_GLAPI *glEvalMesh2) (GLenum mode, GLint =
i1, GLint i2, GLint j1, GLint=0A=
 void (WINE_GLAPI *glEvalPoint1) (GLint i);=0A=
 void (WINE_GLAPI *glEvalPoint2) (GLint i, GLint j);=0A=
 void (WINE_GLAPI *glFeedbackBuffer) (GLsizei size, GLenum type, =
GLfloat* buffer);=0A=
-void (WINE_GLAPI *glFinish) ();=0A=
-void (WINE_GLAPI *glFlush) ();=0A=
 void (WINE_GLAPI *glFogf) (GLenum pname, GLfloat param);=0A=
 void (WINE_GLAPI *glFogfv) (GLenum pname, const GLfloat* params);=0A=
 void (WINE_GLAPI *glFogi) (GLenum pname, GLint param);=0A=
@@ -1139,6 +1137,12 @@ void (WINE_GLAPI *glVertexPointer) (GLint size, =
GLenum type, GLsizei stride, con=0A=
 void (WINE_GLAPI *glViewport) (GLint x, GLint y, GLsizei width, GLsizei =
 void (WINE_GLAPI *glPointParameterfv) (GLenum pname, const GLfloat =
+/* glFinish and glFlush are always loaded from opengl32.dll, this the =
always have=0A=
+ * __stdcall calling convention=0A=
+ */=0A=
+void (__stdcall  *glFinish) ();=0A=
+void (__stdcall  *glFlush) ();=0A=
 /* WGL functions */=0A=
 HGLRC   (WINAPI *pwglCreateContext)(HDC);=0A=
 BOOL    (WINAPI *pwglDeleteContext)(HGLRC);=0A=
@@ -1238,8 +1242,6 @@ BOOL    (WINAPI *pwglShareLists)(HGLRC,HGLRC);=0A=
     USE_GL_FUNC(glEvalPoint1) \=0A=
     USE_GL_FUNC(glEvalPoint2) \=0A=
     USE_GL_FUNC(glFeedbackBuffer) \=0A=
-    USE_GL_FUNC(glFinish) \=0A=
-    USE_GL_FUNC(glFlush) \=0A=
     USE_GL_FUNC(glFogf) \=0A=
     USE_GL_FUNC(glFogfv) \=0A=
     USE_GL_FUNC(glFogi) \=0A=
-- =0A=


More information about the wine-patches mailing list