Henri Verbeet : d3dx8: Implement ID3DXMatrixStack_Push() and ID3DXMatrixStack_Pop().

Alexandre Julliard julliard at winehq.org
Thu Oct 30 10:10:29 CDT 2008


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Oct 29 16:34:21 2008 +0100

d3dx8: Implement ID3DXMatrixStack_Push() and ID3DXMatrixStack_Pop().

Based on a patchset by David Adam.

---

 dlls/d3dx8/math.c |   49 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index eedc115..20d6364 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -691,15 +691,56 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_MultMatrixLocal(ID3DXMatrixStack *ifa
 static HRESULT WINAPI ID3DXMatrixStackImpl_Pop(ID3DXMatrixStack *iface)
 {
     ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
-    FIXME("(%p) : stub\n",This);
-    return E_NOTIMPL;
+
+    TRACE("iface %p\n", iface);
+
+    /* Popping the last element on the stack returns D3D_OK, but does nothing. */
+    if (!This->current) return D3D_OK;
+
+    if (This->current <= This->stack_size / 4 && This->stack_size >= INITIAL_STACK_SIZE * 2)
+    {
+        unsigned int new_size;
+        D3DXMATRIX *new_stack;
+
+        new_size = This->stack_size / 2;
+        new_stack = HeapReAlloc(GetProcessHeap(), 0, This->stack, new_size * sizeof(D3DXMATRIX));
+        if (new_stack)
+        {
+            This->stack_size = new_size;
+            This->stack = new_stack;
+        }
+    }
+
+    --This->current;
+
+    return D3D_OK;
 }
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_Push(ID3DXMatrixStack *iface)
 {
     ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
-    FIXME("(%p) : stub\n",This);
-    return E_NOTIMPL;
+
+    TRACE("iface %p\n", iface);
+
+    if (This->current == This->stack_size - 1)
+    {
+        unsigned int new_size;
+        D3DXMATRIX *new_stack;
+
+        if (This->stack_size > UINT_MAX / 2) return E_OUTOFMEMORY;
+
+        new_size = This->stack_size * 2;
+        new_stack = HeapReAlloc(GetProcessHeap(), 0, This->stack, new_size * sizeof(D3DXMATRIX));
+        if (!new_stack) return E_OUTOFMEMORY;
+
+        This->stack_size = new_size;
+        This->stack = new_stack;
+    }
+
+    ++This->current;
+    This->stack[This->current] = This->stack[This->current - 1];
+
+    return D3D_OK;
 }
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_RotateAxis(ID3DXMatrixStack *iface, CONST D3DXVECTOR3 *pv, FLOAT angle)




More information about the wine-cvs mailing list