[D3D] Some improvements in the BLT DEPTHFILL override

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

 



TR3 was doing a Colorfill of the front buffer... I do not really know why it
should ever be used, but well, if the application does it and we can support
it, why not implement it :-)

At the same time, do the same change in the BPP checkings than on the other
part of the code.

                 Lionel

Changelog:
 - check for buffer type in the Blt Colorfill overide
 - check for ALPHAPIXEL in the Blt Colorfill overide
 - handle 24 bpp in the Blt Colorfill overide
   
-- 
		 Lionel Ulmer - http://www.bbrox.org/
--- dlls/ddraw_CVS/d3ddevice/mesa.c	Tue Jun  3 15:24:23 2003
+++ dlls/ddraw/d3ddevice/mesa.c	Tue Jun  3 18:47:43 2003
@@ -2454,6 +2454,18 @@
         /* This is easy to handle for the D3D Device... */
         DWORD color;
 	D3DRECT rect;
+	GLenum prev_draw;
+	BOOL is_front;
+	
+	/* First check if we BLT to the backbuffer... */
+	if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER)) != 0) {
+	    is_front = FALSE;
+	} else if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER|DDSCAPS_PRIMARYSURFACE)) != 0) {
+	    is_front = TRUE;
+	} else {
+	    ERR("Only BLT override to front or back-buffer is supported for now !\n");
+	    return DDERR_INVALIDPARAMS;
+	}
 
 	/* The color as given in the Blt function is in the format of the frame-buffer...
 	 * 'clear' expect it in ARGB format => we need to do some conversion :-)
@@ -2467,12 +2479,13 @@
 	    } else {
 	        color = 0xFF000000;
 	    }
-	} else if (This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_RGB) {
+	} else if ((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_RGB) &&
+		   (((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) == 0) ||
+		    (This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000))) {
 	    if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 16) &&
-		(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask ==        0xF800) &&
-		(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask ==        0x07E0) &&
-		(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask ==        0x001F) &&
-		(This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x0000)) {
+		(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0xF800) &&
+		(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x07E0) &&
+		(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x001F)) {
 	        if (lpbltfx->u5.dwFillColor == 0xFFFF) {
 		    color = 0xFFFFFFFF;
 		} else {
@@ -2481,15 +2494,14 @@
 			     ((lpbltfx->u5.dwFillColor & 0x07E0) << 5) |
 			     ((lpbltfx->u5.dwFillColor & 0x001F) << 3));
 		}
-	    } else if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) &&
-		       (This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask ==        0x00FF0000) &&
-		       (This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask ==        0x0000FF00) &&
-		       (This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask ==        0x000000FF) &&
-		       (This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000)) {
+	    } else if (((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) ||
+			(This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 24)) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0x00FF0000) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x0000FF00) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x000000FF)) {
 	        color = 0xFF000000 | lpbltfx->u5.dwFillColor;
-	    }
-	    else {
-	        ERR("Wrong surface type for BLT override !\n");
+	    } else {
+	        ERR("Wrong surface type for BLT override (unknown RGB format) !\n");
 		return DDERR_INVALIDPARAMS;
 	    }
 	} else {
@@ -2505,7 +2517,21 @@
 	    rect.u3.x2 = rdst->right;
 	    rect.u4.y2 = rdst->bottom;
 	}
+	
+	ENTER_GL();
+	glGetIntegerv(GL_DRAW_BUFFER, &prev_draw);
+	if (is_front)
+	    glDrawBuffer(GL_FRONT);
+	else
+	    glDrawBuffer(GL_BACK);
+	
 	d3ddevice_clear(This->d3ddevice, rdst != NULL ? 1 : 0, &rect, D3DCLEAR_TARGET, color, 0.0, 0x00000000);
+
+	if ((( is_front) && (prev_draw == GL_BACK)) ||
+	    ((!is_front) && (prev_draw == GL_FRONT)))
+	    glDrawBuffer(prev_draw);
+	LEAVE_GL();
+	
 	return DD_OK;
     }
     return DDERR_INVALIDPARAMS;

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

  Powered by Linux