From f7597dee15307cb46e53d297f7a461c20b058328 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Sun, 1 Jul 2007 23:28:21 +0200
Subject: [PATCH] ddraw: Update the wined3d matrix if a current matrix handle
 is modified.

---
 dlls/ddraw/ddraw_private.h |  1 +
 dlls/ddraw/device.c        | 19 +++++++++++++++++++
 dlls/ddraw/executebuffer.c |  6 ++++++
 3 files changed, 26 insertions(+)

diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index ee194a147dd..2f35643c1a2 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -348,6 +348,7 @@ struct IDirect3DDeviceImpl
     /* Handle management */
     struct HandleEntry      *Handles;
     DWORD                    numHandles;
+    D3DMATRIXHANDLE          world, proj, view;
 };
 
 /* Vtables in various versions */
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 5c21bf92a11..d0cfcdf33e6 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -1406,6 +1406,25 @@ IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
 
     *((D3DMATRIX *) This->Handles[D3DMatHandle - 1].ptr) = *D3DMatrix;
 
+    if(This->world == D3DMatHandle)
+    {
+        IWineD3DDevice_SetTransform(This->wineD3DDevice,
+                                    WINED3DTS_WORLDMATRIX(0),
+                                    (WINED3DMATRIX *) D3DMatrix);
+    }
+    if(This->view == D3DMatHandle)
+    {
+        IWineD3DDevice_SetTransform(This->wineD3DDevice,
+                                    WINED3DTS_VIEW,
+                                    (WINED3DMATRIX *) D3DMatrix);
+    }
+    if(This->proj == D3DMatHandle)
+    {
+        IWineD3DDevice_SetTransform(This->wineD3DDevice,
+                                    WINED3DTS_PROJECTION,
+                                    (WINED3DMATRIX *) D3DMatrix);
+    }
+
     LeaveCriticalSection(&ddraw_cs);
     return D3D_OK;
 }
diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c
index ff0bbdbde35..c44a37ea0d1 100644
--- a/dlls/ddraw/executebuffer.c
+++ b/dlls/ddraw/executebuffer.c
@@ -227,6 +227,12 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
                     } else if(lpDevice->Handles[ci->u2.dwArg[0] - 1].type != DDrawHandle_Matrix) {
                         ERR("Handle %d is not a matrix handle\n", ci->u2.dwArg[0]);
                     } else {
+                        if(ci->u1.drstRenderStateType == D3DTRANSFORMSTATE_WORLD)
+                            lpDevice->world = ci->u2.dwArg[0];
+                        if(ci->u1.drstRenderStateType == D3DTRANSFORMSTATE_VIEW)
+                            lpDevice->view = ci->u2.dwArg[0];
+                        if(ci->u1.drstRenderStateType == D3DTRANSFORMSTATE_PROJECTION)
+                            lpDevice->proj = ci->u2.dwArg[0];
                         IDirect3DDevice7_SetTransform(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
                                                       ci->u1.drstRenderStateType, (LPD3DMATRIX) lpDevice->Handles[ci->u2.dwArg[0] - 1].ptr);
                     }
-- 
GitLab