[D3D] Some texture enumeration 'fixes'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As usual, Windows games only expect ARGB textures (and do not even bother to
check the bitmasks). So, as for the 'packed' texture formats, enumerate only
the 32 bpp ARGB format.

Changelog:
 - only enumerate 32 bpp ARGB texture format and remove RGBA one
 - add support for 32 bpp ARGB texture format

-- 
		 Lionel Ulmer - http://www.bbrox.org/
Index: dlls/ddraw/d3ddevice/mesa.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3ddevice/mesa.c,v
retrieving revision 1.92
diff -u -r1.92 mesa.c
--- dlls/ddraw/d3ddevice/mesa.c	4 May 2003 02:24:03 -0000	1.92
+++ dlls/ddraw/d3ddevice/mesa.c	8 May 2003 16:23:42 -0000
@@ -385,6 +389,8 @@
     pformat->dwSize = sizeof(DDPIXELFORMAT);
     pformat->dwFourCC = 0;
 
+#if 0
+    /* See argument about the RGBA format for 'packed' texture formats */
     TRACE("Enumerating GL_RGBA unpacked (32)\n");
     pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
     pformat->u1.dwRGBBitCount = 32;
@@ -394,6 +400,17 @@
     pformat->u5.dwRGBAlphaBitMask = 0x000000FF;
     if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;
     if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;
+#endif
+    
+    TRACE("Enumerating GL_RGBA unpacked (32)\n");
+    pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
+    pformat->u1.dwRGBBitCount = 32;
+    pformat->u2.dwRBitMask =        0x00FF0000;
+    pformat->u3.dwGBitMask =        0x0000FF00;
+    pformat->u4.dwBBitMask =        0x000000FF;
+    pformat->u5.dwRGBAlphaBitMask = 0xFF000000;
+    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;
+    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;
 
     TRACE("Enumerating GL_RGB unpacked (24)\n");
     pformat->dwFlags = DDPF_RGB;
Index: dlls/ddraw/d3dtexture.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3dtexture.c,v
retrieving revision 1.42
diff -u -r1.42 d3dtexture.c
--- dlls/ddraw/d3dtexture.c	7 Jan 2003 23:08:32 -0000	1.42
+++ dlls/ddraw/d3dtexture.c	8 May 2003 16:23:42 -0000
@@ -386,6 +386,35 @@
 	    } else if ((src_d->ddpfPixelFormat.u2.dwRBitMask ==        0x00FF0000) &&
 		       (src_d->ddpfPixelFormat.u3.dwGBitMask ==        0x0000FF00) &&
 		       (src_d->ddpfPixelFormat.u4.dwBBitMask ==        0x000000FF) &&
+		       (src_d->ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0xFF000000)) {
+	        /* Convert from ARGB (Windows' format) to RGBA.
+		   Note: need to check for GL extensions handling ARGB instead of always converting */
+	        DWORD i;
+		DWORD *src = (DWORD *) src_d->lpSurface, *dst;
+		
+		surface = (DWORD *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, src_d->dwWidth * src_d->dwHeight * sizeof(DWORD));
+		dst = (DWORD *) surface;
+		if (src_d->dwFlags & DDSD_CKSRCBLT) {
+		    for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
+		        DWORD color = *src++;
+			*dst = (color & 0x00FFFFFF) << 8;
+			if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
+			    (color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
+			    *dst |= (color & 0xFF000000) >> 24;
+			dst++;
+		    }
+		} else {
+		    for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
+		        DWORD color = *src++;
+			*dst = (color & 0x00FFFFFF) << 8;
+			*dst |= (color & 0xFF000000) >> 24;
+		    }
+		}
+		format = GL_RGBA;
+		pixel_format = GL_UNSIGNED_INT_8_8_8_8;
+	    } else if ((src_d->ddpfPixelFormat.u2.dwRBitMask ==        0x00FF0000) &&
+		       (src_d->ddpfPixelFormat.u3.dwGBitMask ==        0x0000FF00) &&
+		       (src_d->ddpfPixelFormat.u4.dwBBitMask ==        0x000000FF) &&
 		       (src_d->ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000)) {
 	        /* Just add an alpha component and handle color-keying... */
 	        DWORD i;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux