H. Verbeet : wined3d: When switching color material, apply the material we were previously tracking.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jan 18 06:45:05 CST 2007


Module: wine
Branch: master
Commit: d429ff5b6917fc27cf9898b353d3c716553e6392
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d429ff5b6917fc27cf9898b353d3c716553e6392

Author: H. Verbeet <hverbeet at gmail.com>
Date:   Wed Jan 17 21:41:35 2007 +0100

wined3d: When switching color material, apply the material we were previously tracking.

This fixes a regression introduced by 329670c7f129343ef0086f76b08a40d0fd5e3242.

---

 dlls/wined3d/state.c |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index b0f74c7..adcd9c5 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -812,14 +812,15 @@ static void state_fogdensity(DWORD state
 
 /* TODO: Merge with primitive type + init_materials()!! */
 static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) {
+    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)stateblock->wineD3DDevice;
     GLenum Parm = 0;
-    WineDirect3DStridedData *diffuse = &stateblock->wineD3DDevice->strided_streams.u.s.diffuse;
+    WineDirect3DStridedData *diffuse = &device->strided_streams.u.s.diffuse;
     BOOL isDiffuseSupplied;
 
     /* Depends on the decoded vertex declaration to read the existance of diffuse data.
      * The vertex declaration will call this function if the fixed function pipeline is used.
      */
-    if(isStateDirty(stateblock->wineD3DDevice, STATE_VDECL)) {
+    if(isStateDirty(device, STATE_VDECL)) {
         return;
     }
 
@@ -847,6 +848,9 @@ static void state_colormat(DWORD state,
         }
     }
 
+    /* Nothing changed, return. */
+    if (Parm == device->tracking_parm) return;
+
     if(!Parm) {
         glDisable(GL_COLOR_MATERIAL);
         checkGLcall("glDisable GL_COLOR_MATERIAL");
@@ -856,6 +860,45 @@ static void state_colormat(DWORD state,
         glEnable(GL_COLOR_MATERIAL);
         checkGLcall("glEnable(GL_COLOR_MATERIAL)");
     }
+
+    /* Apparently calls to glMaterialfv are ignored for properties we're
+     * tracking with glColorMaterial, so apply those here. */
+    switch (device->tracking_parm) {
+        case GL_AMBIENT_AND_DIFFUSE:
+            glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
+            glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
+            checkGLcall("glMaterialfv");
+            break;
+
+        case GL_DIFFUSE:
+            glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
+            checkGLcall("glMaterialfv");
+            break;
+
+        case GL_AMBIENT:
+            glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
+            checkGLcall("glMaterialfv");
+            break;
+
+        case GL_EMISSION:
+            glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*)&device->updateStateBlock->material.Emissive);
+            checkGLcall("glMaterialfv");
+            break;
+
+        case GL_SPECULAR:
+            /* Only change material color if specular is enabled, otherwise it is set to black */
+            if (device->stateBlock->renderState[WINED3DRS_SPECULARENABLE]) {
+                glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*)&device->updateStateBlock->material.Specular);
+                checkGLcall("glMaterialfv");
+            } else {
+                float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+                glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
+                checkGLcall("glMaterialfv");
+            }
+            break;
+    }
+
+    device->tracking_parm = Parm;
 }
 
 static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock) {




More information about the wine-cvs mailing list