[WINED3D 3/9] Add D3DCLEAR codes to the WINED3D namespace

Ivan Gyurdiev ivg231 at gmail.com
Tue Oct 31 02:17:43 CST 2006


In order to confuse me, someone defined them differently in ddraw, d3d8, 
d3d9:

i.e: { 0x00000001, 0x00000002, 0x00000003 } in ddraw
     { 1, 2, 3 } in d3d8
     { 0x00000001L, 0x00000002L, 0x00000003L } in d3d9.

All of the above must fit in a 32-bit DWORD eventually.
The first one was chosen for our purposes - I'm surprised the compiler 
doesn't complain on the third one.
-------------- next part --------------
---
 dlls/wined3d/device.c        |   18 +++++++++---------
 dlls/wined3d/surface.c       |    2 +-
 dlls/wined3d/swapchain.c     |    4 ++--
 include/wine/wined3d_types.h |    5 +++++
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 650c739..b6e56c1 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2133,7 +2133,7 @@ #endif
     TRACE("(%p) All defaults now set up, leaving Init3D with %p\n", This, This);
 
     /* Clear the screen */
-    IWineD3DDevice_Clear((IWineD3DDevice *) This, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0);
+    IWineD3DDevice_Clear((IWineD3DDevice *) This, 0, NULL, WINED3DCLEAR_STENCIL|WINED3DCLEAR_ZBUFFER|WINED3DCLEAR_TARGET, 0x00, 1.0, 0);
 
     This->d3d_initialized = TRUE;
     return WINED3D_OK;
@@ -6028,8 +6028,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl
                                         DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
 
-    /* TODO: From MSDN This method fails if you specify the D3DCLEAR_ZBUFFER or D3DCLEAR_STENCIL flags when the
-      render target does not have an attached depth buffer. Similarly, if you specify the D3DCLEAR_STENCIL flag
+    /* TODO: From MSDN This method fails if you specify the WINED3DCLEAR_ZBUFFER or WINED3DCLEAR_STENCIL flags when the
+      render target does not have an attached depth buffer. Similarly, if you specify the WINED3DCLEAR_STENCIL flag
       when the depth-buffer format does not contain stencil buffer information, this method fails. */
     GLbitfield     glMask = 0;
     GLboolean      old_ztest;
@@ -6054,7 +6054,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     }
 
     /* Only set the values up once, as they are not changing */
-    if (Flags & D3DCLEAR_STENCIL) {
+    if (Flags & WINED3DCLEAR_STENCIL) {
         glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value);
         glClearStencil(Stencil);
         checkGLcall("glClearStencil");
@@ -6062,7 +6062,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
         glStencilMask(0xFFFFFFFF);
     }
 
-    if (Flags & D3DCLEAR_ZBUFFER) {
+    if (Flags & WINED3DCLEAR_ZBUFFER) {
         glGetBooleanv(GL_DEPTH_WRITEMASK, &old_ztest);
         glDepthMask(GL_TRUE);
         glGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value);
@@ -6071,7 +6071,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
         glMask = glMask | GL_DEPTH_BUFFER_BIT;
     }
 
-    if (Flags & D3DCLEAR_TARGET) {
+    if (Flags & WINED3DCLEAR_TARGET) {
         TRACE("Clearing screen with glClear to color %x\n", Color);
         glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value);
         glClearColor(D3DCOLOR_R(Color),
@@ -6115,15 +6115,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     }
 
     /* Restore the old values (why..?) */
-    if (Flags & D3DCLEAR_STENCIL) {
+    if (Flags & WINED3DCLEAR_STENCIL) {
         glClearStencil(old_stencil_clear_value);
         glStencilMask(This->stateBlock->renderState[WINED3DRS_STENCILWRITEMASK]);
     }
-    if (Flags & D3DCLEAR_ZBUFFER) {
+    if (Flags & WINED3DCLEAR_ZBUFFER) {
         glDepthMask(old_ztest);
         glClearDepth(old_z_clear_value);
     }
-    if (Flags & D3DCLEAR_TARGET) {
+    if (Flags & WINED3DCLEAR_TARGET) {
         glClearColor(old_color_clear_value[0],
                      old_color_clear_value[1],
                      old_color_clear_value[2],
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 365d047..d0f44cf 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2721,7 +2721,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOv
         IWineD3DDevice_Clear( (IWineD3DDevice *) myDevice,
                               1 /* Number of rectangles */,
                               &rect,
-                              D3DCLEAR_TARGET,
+                              WINED3DCLEAR_TARGET,
                               color,
                               0.0 /* Z */,
                               0 /* Stencil */);
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 287153d..1ff01a2 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -364,12 +364,12 @@ #endif
 
         TRACE("Clearing\n");
 
-        IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0);
+        IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, WINED3DCLEAR_STENCIL|WINED3DCLEAR_ZBUFFER|WINED3DCLEAR_TARGET, 0x00, 1.0, 0);
 
     } else {
         TRACE("Clearing z/stencil buffer\n");
 
-        IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER, 0x00, 1.0, 0);
+        IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, WINED3DCLEAR_STENCIL|WINED3DCLEAR_ZBUFFER, 0x00, 1.0, 0);
     }
 
     if(!(((IWineD3DSurfaceImpl *) This->frontBuffer)->Flags   & SFLAG_GLDIRTY) ||
diff --git a/include/wine/wined3d_types.h b/include/wine/wined3d_types.h
index 3715d2a..1787859 100644
--- a/include/wine/wined3d_types.h
+++ b/include/wine/wined3d_types.h
@@ -1523,4 +1523,9 @@ #define WINED3DFVF_TEXCOORDSIZE2(CoordIn
 #define WINED3DFVF_TEXCOORDSIZE3(CoordIndex) (WINED3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
 #define WINED3DFVF_TEXCOORDSIZE4(CoordIndex) (WINED3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
 
+/* Clear flags */
+#define WINED3DCLEAR_TARGET   0x00000001
+#define WINED3DCLEAR_ZBUFFER  0x00000002
+#define WINED3DCLEAR_STENCIL  0x00000004
+
 #endif
-- 
1.4.2.4



More information about the wine-patches mailing list