[D3D] Start to use the extension code.

Lionel Ulmer lionel.ulmer at free.fr
Sat Aug 2 11:07:33 CDT 2003


Changelog:
 - proper MIRROR texture address support

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
--- dlls/ddraw_CVS/d3ddevice/mesa.c	Sat Aug  2 08:51:32 2003
+++ dlls/ddraw/d3ddevice/mesa.c	Sat Aug  2 18:01:31 2003
@@ -32,6 +32,8 @@
 #include "ddraw.h"
 #include "d3d.h"
 #include "wine/debug.h"
+#include "wine/port.h"
+#include "wine/library.h"
 
 #include "mesa_private.h"
 #include "main.h"
@@ -66,6 +68,7 @@
 
 /* This is filled at DLL loading time */
 static D3DDEVICEDESC7 opengl_device_caps;
+GL_EXTENSIONS_LIST GL_extensions;
 
 static void draw_primitive_strided(IDirect3DDeviceImpl *This,
 				   D3DPRIMITIVETYPE d3dptPrimitiveType,
@@ -1749,11 +1752,13 @@
 	        case D3DTADDRESS_WRAP:   TRACE(" Stage type is : %s => D3DTADDRESS_WRAP\n", type); break;
 	        case D3DTADDRESS_CLAMP:  TRACE(" Stage type is : %s => D3DTADDRESS_CLAMP\n", type); break;
 	        case D3DTADDRESS_BORDER: TRACE(" Stage type is : %s => D3DTADDRESS_BORDER\n", type); break;
-#if defined(GL_VERSION_1_4)
-		case D3DTADDRESS_MIRROR: TRACE(" Stage type is : %s => D3DTADDRESS_MIRROR\n", type); break;
-#elif defined(GL_ARB_texture_mirrored_repeat)
-		case D3DTADDRESS_MIRROR: TRACE(" Stage type is : %s => D3DTADDRESS_MIRROR\n", type); break;
-#endif
+		case D3DTADDRESS_MIRROR:
+		    if (GL_extensions.mirrored_repeat == TRUE) {
+			TRACE(" Stage type is : %s => D3DTADDRESS_MIRROR\n", type);
+		    } else {
+			FIXME(" Stage type is : %s => D3DTADDRESS_MIRROR - not supported by GL !\n", type);
+		    }
+		    break;
 	        default: FIXME(" Unhandled stage type : %s => %08lx\n", type, dwState); break;
 	    }
         } break;
@@ -3787,6 +3792,9 @@
     pc->dwTextureBlendCaps = D3DPTBLENDCAPS_ADD | D3DPTBLENDCAPS_COPY | D3DPTBLENDCAPS_DECAL | D3DPTBLENDCAPS_DECALALPHA | D3DPTBLENDCAPS_DECALMASK |
       D3DPTBLENDCAPS_MODULATE | D3DPTBLENDCAPS_MODULATEALPHA | D3DPTBLENDCAPS_MODULATEMASK;
     pc->dwTextureAddressCaps = D3DPTADDRESSCAPS_BORDER | D3DPTADDRESSCAPS_CLAMP | D3DPTADDRESSCAPS_WRAP | D3DPTADDRESSCAPS_INDEPENDENTUV;
+    if (GL_extensions.mirrored_repeat == TRUE) {
+	pc->dwTextureAddressCaps |= D3DPTADDRESSCAPS_MIRROR;
+    }
     pc->dwStippleWidth = 32;
     pc->dwStippleHeight = 32;
 }
@@ -3863,7 +3871,12 @@
     XWindowAttributes win_attr;
     GLXContext gl_context;
     int num;
-
+    const char *glExtensions;
+    const char *glVersion;
+    const char *glXExtensions = NULL;
+    const void *(*pglXGetProcAddressARB)(const GLubyte *) = NULL;
+    int major, minor, patch;
+    
     TRACE("Initializing GL...\n");
     
     /* Get a default rendering context to have the 'caps' function query some info from GL */    
@@ -3898,7 +3911,33 @@
 	return FALSE;	
     }
     
-    /* Then, query all extensions and fill our extension context. TODO :-) */
+    /* Then, query all extensions */
+    glXExtensions = glXQueryExtensionsString(display, DefaultScreen(display));
+    glExtensions = (const char *) glGetString(GL_EXTENSIONS);
+    glVersion = (const char *) glGetString(GL_VERSION);
+    if ((glXExtensions != NULL) && (gl_handle != NULL) && (strstr(glXExtensions, "GLX_ARB_get_proc_address"))) {
+	pglXGetProcAddressARB = wine_dlsym(gl_handle, "glXGetProcAddressARB", NULL, 0);
+    }
+    
+    /* Parse the GL version string */
+    sscanf(glVersion, "%d.%d.%d", &major, &minor, &patch);
+    TRACE("GL version %d.%d.%d\n", major, minor, patch);
+
+    /* And starts to fill the extension context properly */
+    memset(&GL_extensions, 0, sizeof(GL_extensions));
+    TRACE("GL supports following extensions used by Wine :\n");
+    
+    /* Mirrored Repeat extension :
+        - GL_ARB_texture_mirrored_repeat
+	- GL_IBM_texture_mirrored_repeat
+	- GL >= 1.4
+    */
+    if ((strstr(glExtensions, "GL_ARB_texture_mirrored_repeat")) ||
+	(strstr(glExtensions, "GL_IBM_texture_mirrored_repeat")) ||
+	((major >= 1) && (minor >= 4))) {
+	TRACE(" - mirrored repeat\n");
+	GL_extensions.mirrored_repeat = TRUE;
+    }
     
     /* Fill the D3D capabilities according to what GL tells us... */
     fill_caps();
--- dlls/ddraw_CVS/d3dtexture.c	Fri Aug  1 21:38:18 2003
+++ dlls/ddraw/d3dtexture.c	Sat Aug  2 17:49:40 2003
@@ -143,11 +143,17 @@
         case D3DTADDRESS_WRAP:   gl_state = GL_REPEAT; break;
 	case D3DTADDRESS_CLAMP:  gl_state = GL_CLAMP; break;
 	case D3DTADDRESS_BORDER: gl_state = GL_CLAMP_TO_EDGE; break;
-#if defined(GL_VERSION_1_4)
-	case D3DTADDRESS_MIRROR: gl_state = GL_MIRRORED_REPEAT; break;
-#elif defined(GL_ARB_texture_mirrored_repeat)
-	case D3DTADDRESS_MIRROR: gl_state = GL_MIRRORED_REPEAT_ARB; break;
-#endif
+	case D3DTADDRESS_MIRROR:
+	    if (GL_extensions.mirrored_repeat == TRUE) {
+		gl_state = GL_MIRRORED_REPEAT_WINE;
+	    } else {
+		gl_state = GL_REPEAT;
+		/* This is a TRACE instead of a FIXME as the FIXME was already printed when the game
+		   actually set D3DTADDRESS_MIRROR.
+		*/
+		TRACE(" setting GL_REPEAT instead of GL_MIRRORED_REPEAT.\n");
+	    }
+	break;
 	default:                 gl_state = GL_REPEAT; break;
     }
     return gl_state;
--- dlls/ddraw_CVS/mesa_private.h	Fri Aug  1 21:38:18 2003
+++ dlls/ddraw/mesa_private.h	Sat Aug  2 17:34:56 2003
@@ -154,6 +154,17 @@
     LPVOID vertices;
 } IDirect3DVertexBufferGLImpl;
 
+/* This is for GL extension support.
+   
+   This can contain either only a boolean if no function pointer exists or a set
+   of function pointers.
+*/
+typedef struct {
+    /* Mirrored Repeat */
+    BOOLEAN mirrored_repeat;
+} GL_EXTENSIONS_LIST; 
+extern GL_EXTENSIONS_LIST GL_extensions;
+
 /* All non-static functions 'exported' by various sub-objects */
 extern HRESULT direct3d_create(IDirectDrawImpl *This);
 extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
--- dlls/ddraw_CVS/gl_api.h	Wed Jun 18 23:14:02 2003
+++ dlls/ddraw/gl_api.h	Sat Aug  2 17:10:31 2003
@@ -61,6 +61,7 @@
 GL_API_FUNCTION(glGetError)
 GL_API_FUNCTION(glGetFloatv)
 GL_API_FUNCTION(glGetIntegerv)
+GL_API_FUNCTION(glGetString)
 GL_API_FUNCTION(glGetTexEnviv)
 GL_API_FUNCTION(glGetTexParameteriv)
 GL_API_FUNCTION(glHint)
@@ -105,4 +106,5 @@
 GL_API_FUNCTION(glXCreateContext)
 GL_API_FUNCTION(glXDestroyContext)
 GL_API_FUNCTION(glXMakeCurrent)
+GL_API_FUNCTION(glXQueryExtensionsString)
 GL_API_FUNCTION(glXSwapBuffers)
--- dlls/ddraw_CVS/gl_private.h	Wed Jun 18 23:14:02 2003
+++ dlls/ddraw/gl_private.h	Sat Aug  2 17:44:10 2003
@@ -49,6 +49,13 @@
 #include "gl_api.h"
 #undef GL_API_FUNCTION
 
+/* This is also where I store our private extension defines...
+   I know that Raphael won't like it, but well, I prefer doing that than battling 10 different headers :-)
+
+   Note: this is perfectly 'legal' as the three variants of the enum have exactly the same value
+*/
+#define GL_MIRRORED_REPEAT_WINE 0x8370
+
 #ifndef GLPRIVATE_NO_REDEFINE
 
 #define glAlphaFunc pglAlphaFunc
@@ -86,6 +93,7 @@
 #define glGetError pglGetError
 #define glGetFloatv pglGetFloatv
 #define glGetIntegerv pglGetIntegerv
+#define glGetString pglGetString
 #define glGetTexEnviv pglGetTexEnviv
 #define glGetTexParameteriv pglGetTexParameteriv
 #define glHint pglHint
@@ -130,6 +138,7 @@
 #define glXCreateContext pglXCreateContext
 #define glXDestroyContext pglXDestroyContext
 #define glXMakeCurrent pglXMakeCurrent
+#define glXQueryExtensionsString pglXQueryExtensionsString
 #define glXSwapBuffers pglXSwapBuffers
 
 #endif /* GLPRIVATE_NO_REDEFINE */


More information about the wine-patches mailing list