DDraw: Implement GetRenderState for D3DRENDERSTATE_TEXTUREHANDLE

Stefan Dösinger stefandoesinger at gmx.at
Sat Oct 14 17:01:23 CDT 2006


D3DRENDERSTATE_TEXTUREHANDLE is wrapped to IWineD3DDevice_SetTexture in 
SetRenderState. GetRenderState for D3DRENDERSTATE_TEXTUREHANDLE is in Theory 
uncallable because GetRenderState didn't exist in d3d1 when the texture 
handle state was used, but a newer app might call it.

MINFILTER, MAXFILTER, TEXTUREADDRESS[U/V] will need the same.
-------------- next part --------------
From 64503de424d7b91722e0fc56f2bd98a7218aaf7b Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Sat, 14 Oct 2006 23:56:22 +0200
Subject: [PATCH] DDraw: Implement GetRenderState for D3DRENDERSTATE_TEXTUREHANDLE
---
 dlls/ddraw/device.c |   45 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 1401499..09d2ca9 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -2094,16 +2094,53 @@ IDirect3DDeviceImpl_7_GetRenderState(IDi
                                      DWORD *Value)
 {
     ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
+    HRESULT hr;
     TRACE("(%p)->(%08x,%p): Relay\n", This, RenderStateType, Value);
 
     if(!Value)
         return DDERR_INVALIDPARAMS;
 
-    /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
+    switch(RenderStateType)
+    {
+        case D3DRENDERSTATE_TEXTUREHANDLE:
+        {
+            /* This state is wrapped to SetTexture in SetRenderState, so
+             * it has to be wrapped to GetTexture here
+             */
+            IWineD3DBaseTexture *tex = NULL;
+            *Value = 0;
+
+            hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
+                                           0,
+                                           &tex);
+
+            if(hr == WINED3D_OK && tex)
+            {
+                IDirectDrawSurface7 *parent = NULL;
+                hr = IWineD3DBaseTexture_GetParent(tex,
+                                                   (IUnknown **) &parent);
+                if(parent)
+                {
+                    /* The parent of the texture is the IDirectDrawSurface7 interface
+                     * of the ddraw surface
+                     */
+                    IDirectDrawSurfaceImpl *texImpl = ICOM_OBJECT(IDirectDrawSurfaceImpl,
+                                                                  IDirectDrawSurface7,
+                                                                  parent);
+                    *Value = texImpl->Handle;
+                    IDirectDrawSurface7_Release(parent);
+                }
+                IWineD3DBaseTexture_Release(tex);
+            }
+            return hr;
+        }
 
-    return IWineD3DDevice_GetRenderState(This->wineD3DDevice,
-                                         RenderStateType,
-                                         Value);
+        default:
+            /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
+            return IWineD3DDevice_GetRenderState(This->wineD3DDevice,
+                                                 RenderStateType,
+                                                 Value);
+    }
 }
 
 static HRESULT WINAPI
-- 
1.4.1.1



More information about the wine-patches mailing list