WineD3D Opengl 2.x compile fix

Roderick Colenbrander thunderbird2k at gmx.net
Thu Mar 2 06:27:13 CST 2006


Hi,

Recently some OpenGL 2.x specific function calls were added to WineD3D. In 
order to let this compile correctly on older GL implementations without using 
ifdefs, this patch dynamicly loads the opengl 2.x call in question. In order 
to make this possible the opengl version is stored inside the gl_info 
structure. In case the major version is 2 this function is loaded in a 
similar way to opengl extensions. (The function pointers which are added to 
wine_gl.h come from vitaly his patch)

Regards,
Roderick Colenbrander
-------------- next part --------------
Index: dlls/wined3d/device.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/device.c,v
retrieving revision 1.138
diff -u -r1.138 device.c
--- dlls/wined3d/device.c	28 Feb 2006 12:10:51 -0000	1.138
+++ dlls/wined3d/device.c	2 Mar 2006 12:22:15 -0000
@@ -3767,8 +3767,12 @@
         }
 
         if(!This->stateBlock->renderState[WINED3DRS_TWOSIDEDSTENCILMODE]) {
-            glStencilOpSeparate(GL_BACK, stencilFail, depthFail, stencilPass);
-            checkGLcall("glStencilOpSeparate(GL_BACK,...)");
+            if(GL_SUPPORT(GL2_STENCIL_OP_SEPARATE)) {
+                GL_EXTCALL(glStencilOpSeparate(GL_BACK, stencilFail, depthFail, stencilPass));
+                checkGLcall("glStencilOpSeparate(GL_BACK,...)");
+            } else {
+                WARN("Unsupported in local OpenGL implementation: glSteniclOpSeparate\n");
+            }
         } else {
             glStencilOp(stencilFail, depthFail, stencilPass);
             checkGLcall("glStencilOp(...)");
Index: dlls/wined3d/directx.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/directx.c,v
retrieving revision 1.73
diff -u -r1.73 directx.c
--- dlls/wined3d/directx.c	27 Feb 2006 15:34:44 -0000	1.73
+++ dlls/wined3d/directx.c	2 Mar 2006 12:22:15 -0000
@@ -30,6 +30,8 @@
 #include "config.h"
 #include "wined3d_private.h"
 
+#include <stdio.h> /* Needed for sscanf */
+
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
 #define GLINFO_LOCATION This->gl_info
@@ -211,7 +213,7 @@
     GLint       gl_max;
     GLfloat     gl_float;
     Bool        test = 0;
-    int         major, minor;
+    int         major, minor, release;
     WineD3D_Context *fake_ctx = NULL;
     BOOL        gotContext    = FALSE;
     int         i;
@@ -264,6 +266,9 @@
     /* Parse the GL_VERSION field into major and minor information */
     gl_string = (const char *) glGetString(GL_VERSION);
     if (gl_string != NULL) {
+        sscanf(gl_string, "%d.%d.%d", &major, &minor, &release);
+        gl_info->gl_version = MAKEDWORD_GL_VERSION(major, minor, release);
+        TRACE_(d3d_caps)("GL_VERSION: %d %d %d\n", major, minor, release);
 
         switch (gl_info->gl_vendor) {
         case VENDOR_NVIDIA:
@@ -654,6 +659,11 @@
 
             if (*GL_Extensions == ' ') GL_Extensions++;
         }
+
+        /* Add OpenGL 2.x features as extensions to the supported list */
+        if(WINE_GL_VERSION_MAJOR(gl_info->gl_version) == 2) {
+            gl_info->supported[GL2_STENCIL_OP_SEPARATE] = TRUE;
+        }
     }
 
     /* Load all the lookup tables
Index: include/wine/wined3d_gl.h
===================================================================
RCS file: /home/wine/wine/include/wine/wined3d_gl.h,v
retrieving revision 1.15
diff -u -r1.15 wined3d_gl.h
--- include/wine/wined3d_gl.h	5 Feb 2006 12:55:08 -0000	1.15
+++ include/wine/wined3d_gl.h	2 Mar 2006 12:22:16 -0000
@@ -803,7 +803,9 @@
 typedef void (APIENTRY * PGLFNENDOCCLUSIONQUERYNVPROC) (void);
 typedef void (APIENTRY * PGLFNGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
 typedef void (APIENTRY * PGLFNGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
-
+/* OpenGL 2.0 */
+typedef void (APIENTRY * PGLFNSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRY * PGLFNSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask);
 
 /****************************************************
  * OpenGL Official Version 
@@ -907,6 +909,8 @@
 } GL_PSVersion;
 
 #define MAKEDWORD_VERSION(maj, min)  ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF)
+#define MAKEDWORD_GL_VERSION(maj, min, rel)  ((maj & 0xFF) << 16) | ((min & 0xFF) << 8) | (rel & 0xFF)
+#define WINE_GL_VERSION_MAJOR(version) ((version >> 16) & 0xFF)
 
 /* OpenGL Supported Extensions (ARB and EXT) */
 typedef enum _GL_SupportedExt {
@@ -960,6 +964,8 @@
   ATI_TEXTURE_ENV_COMBINE3,
   ATI_TEXTURE_MIRROR_ONCE,
   EXT_VERTEX_SHADER,
+  /* OpenGL 2.x */
+  GL2_STENCIL_OP_SEPARATE,
 
   OPENGL_SUPPORTED_EXT_END
 } GL_SupportedExt;
@@ -1032,6 +1038,9 @@
     USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC,      glVertexAttribPointerARB); \
     USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC,  glEnableVertexAttribArrayARB); \
     USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArrayARB); \
+    /* OpenGL 2.0 */ \
+    USE_GL_FUNC(PGLFNSTENCILOPSEPARATEPROC, glStencilOpSeparate); \
+    USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEPROC, glStencilFuncSeparate); \
 
 #define GLX_EXT_FUNCS_GEN \
     /** GLX_VERSION_1_3 **/ \


More information about the wine-patches mailing list