[3/16] WineD3D: Move WINED3DTS_MODELVIEW to the state table

Stefan Dösinger stefandoesinger at gmx.at
Mon Jan 1 17:14:32 CST 2007


This patch moves the light updating part of the modelview matrix to  
the state table. Not yet the actual  matrix application because that  
interacts with the world matrix, which will follow later.

-------------- next part --------------
From f02b5d90737d0394243749c1802b411b2bc7d56e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Stefan_D=C3=B6singer?= <stefan at imac.local>
Date: Tue, 26 Dec 2006 23:04:59 +0100
Subject: [PATCH] WineD3D: Move WINED3DTS_MODELVIEW to the state table

---
 dlls/wined3d/device.c |   43 +++----------------------------------------
 dlls/wined3d/state.c  |   40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 38afc4f..d2898d3 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2372,53 +2372,16 @@ static HRESULT  WINAPI  IWineD3DDeviceIm
         return WINED3D_OK;
     }
 
-    /* Now we really are going to have to change a matrix */
-    ENTER_GL();
-
     if (d3dts >= WINED3DTS_TEXTURE0 && d3dts <= WINED3DTS_TEXTURE7) { /* handle texture matrices */
         /* This is now set with the texture unit states, it may be a good idea to flag the change though! */
     } else if (d3dts == WINED3DTS_VIEW) { /* handle the VIEW matrice */
-        unsigned int k;
-
-        /* If we are changing the View matrix, reset the light and clipping planes to the new view
-         * NOTE: We have to reset the positions even if the light/plane is not currently
-         *       enabled, since the call to enable it will not reset the position.
-         * NOTE2: Apparently texture transforms do NOT need reapplying
-         */
-
-        PLIGHTINFOEL *lightChain = NULL;
-        This->modelview_valid = FALSE;
-        This->view_ident = !memcmp(lpmatrix, identity, 16 * sizeof(float));
-
-        glMatrixMode(GL_MODELVIEW);
-        checkGLcall("glMatrixMode(GL_MODELVIEW)");
-        glPushMatrix();
-        glLoadMatrixf((const float *)lpmatrix);
-        checkGLcall("glLoadMatrixf(...)");
-
-        /* Reset lights */
-        lightChain = This->stateBlock->lights;
-        while (lightChain && lightChain->glIndex != -1) {
-            glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_POSITION, lightChain->lightPosn);
-            checkGLcall("glLightfv posn");
-            glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_SPOT_DIRECTION, lightChain->lightDirn);
-            checkGLcall("glLightfv dirn");
-            lightChain = lightChain->next;
-        }
-
-        /* Reset Clipping Planes if clipping is enabled */
-        for (k = 0; k < GL_LIMITS(clipplanes); k++) {
-            glClipPlane(GL_CLIP_PLANE0 + k, This->stateBlock->clipplane[k]);
-            checkGLcall("glClipPlane");
-        }
-        glPopMatrix();
-
+		This->view_ident = !memcmp(lpmatrix, identity, 16 * sizeof(float));
+        /* Handled by the state manager */
     } else { /* What was requested!?? */
         WARN("invalid matrix specified: %i\n", d3dts);
     }
 
-    /* Release lock, all done */
-    LEAVE_GL();
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TRANSFORM(d3dts));
     return WINED3D_OK;
 
 }
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 5a79d22..ed50a87 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1805,6 +1805,44 @@ #endif
     }
 }
 
+static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock) {
+    unsigned int k;
+
+    /* If we are changing the View matrix, reset the light and clipping planes to the new view
+     * NOTE: We have to reset the positions even if the light/plane is not currently
+     *       enabled, since the call to enable it will not reset the position.
+     * NOTE2: Apparently texture transforms do NOT need reapplying
+     */
+
+    PLIGHTINFOEL *lightChain = NULL;
+    stateblock->wineD3DDevice->modelview_valid = FALSE;
+
+    glMatrixMode(GL_MODELVIEW);
+    checkGLcall("glMatrixMode(GL_MODELVIEW)");
+    glPushMatrix();
+    checkGLcall("glPushMatrix()");
+    glLoadMatrixf((float *)(float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
+    checkGLcall("glLoadMatrixf(...)");
+
+    /* Reset lights. TODO: Call light apply func */
+    lightChain = stateblock->lights;
+    while (lightChain && lightChain->glIndex != -1) {
+        glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_POSITION, lightChain->lightPosn);
+        checkGLcall("glLightfv posn");
+        glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_SPOT_DIRECTION, lightChain->lightDirn);
+        checkGLcall("glLightfv dirn");
+        lightChain = lightChain->next;
+    }
+
+    /* Reset Clipping Planes if clipping is enabled. TODO: Call clipplane apply func */
+    for (k = 0; k < GL_LIMITS(clipplanes); k++) {
+        glClipPlane(GL_CLIP_PLANE0 + k, stateblock->clipplane[k]);
+        checkGLcall("glClipPlane");
+    }
+    glPopMatrix();
+    checkGLcall("glPopMatrix()");
+}
+
 const struct StateEntry StateTable[] =
 {
       /* State name                                         representative,                                     apply function */
@@ -2306,7 +2344,7 @@ const struct StateEntry StateTable[] =
     { /*  , Pixel Shader                            */      STATE_PIXELSHADER,                                  pixelshader         },
       /* Transform states follow                    */
     { /*  1, undefined                              */      0,                                                  state_undefined     },
-    { /*  2, WINED3DTS_VIEW                         */      STATE_TRANSFORM(WINED3DTS_VIEW),                    state_undefined     },
+    { /*  2, WINED3DTS_VIEW                         */      STATE_TRANSFORM(WINED3DTS_VIEW),                    transform_view      },
     { /*  3, WINED3DTS_PROJECTION                   */      STATE_TRANSFORM(WINED3DTS_PROJECTION),              state_undefined     },
     { /*  4, undefined                              */      0,                                                  state_undefined     },
     { /*  5, undefined                              */      0,                                                  state_undefined     },
-- 
1.4.2.4



More information about the wine-patches mailing list