[DDraw] Fix AoE2 font rendering (in most cases)

Lionel Ulmer lionel.ulmer at free.fr
Sun Nov 13 08:52:39 CST 2005


Hi all,

AoE2 was rendering to a 8 bit off-screen DSurface using GetDC / ReleaseDC
and that without having attached a palette to it... Our DIB engine did not
like this at all which made all fonts come out black.

The attached patch ('hack' :-) ) simply takes the palette of the front
buffer (if any) and attach it to the DIB before rendering to it.

Note that the proper fix would be in the DIB engine itself but I have no
idea how to (nor the means to) fix it there (if possible using the X11
engine we currently have).

        Lionel

Changelog:
 - use the front buffer palette for DC operations on off-screen buffers

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: dlls/ddraw/surface_main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/surface_main.c,v
retrieving revision 1.8
diff -u -r1.8 surface_main.c
--- dlls/ddraw/surface_main.c	10 Nov 2005 12:14:59 -0000	1.8
+++ dlls/ddraw/surface_main.c	13 Nov 2005 14:08:56 -0000
@@ -900,6 +900,31 @@
     }
 
     hr = This->get_dc(This, &This->hDC);
+
+    if ((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) &&
+	(This->palette == NULL)) {
+	IDirectDrawImpl *ddraw = This->ddraw_owner;
+	IDirectDrawSurfaceImpl *surf;
+	
+	for (surf = ddraw->surfaces; surf != NULL; surf = surf->next_ddraw) {
+	    if (((surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER)) == (DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER)) &&
+		(surf->palette != NULL)) {
+		RGBQUAD col[256];
+		IDirectDrawPaletteImpl *pal = surf->palette;
+		unsigned int n;
+		for (n=0; n<256; n++) {
+		    col[n].rgbRed   = pal->palents[n].peRed;
+		    col[n].rgbGreen = pal->palents[n].peGreen;
+		    col[n].rgbBlue  = pal->palents[n].peBlue;
+		    col[n].rgbReserved = 0;
+		}
+		SetDIBColorTable(This->hDC, 0, 256, col);
+		break;
+	    }
+	}
+
+    }
+    
     if (SUCCEEDED(hr))
     {
 	TRACE("returning %p\n",This->hDC);


More information about the wine-patches mailing list