No subject


Wed Feb 20 09:39:33 CST 2008


ne=0A=0A---=0A dlls/d3dx9_36/offscreen.c |   94 +++++++++++++++++++++++++++=
+++++++++++++++++-=0A 1 files changed, 93 insertions(+), 1 deletions(-)=0A=
=0Adiff --git a/dlls/d3dx9_36/offscreen.c b/dlls/d3dx9_36/offscreen.c=0Aind=
ex d6e4e92..0fcbd8c 100644=0A--- a/dlls/d3dx9_36/offscreen.c=0A+++ b/dlls/d=
3dx9_36/offscreen.c=0A@@ -54,6 +54,11 @@ static ULONG WINAPI ID3DXRenderToS=
urfaceImpl_Release(LPD3DXRENDERTOSURFACE iface=0A     TRACE("(%p): ReleaseR=
ef to %d\n", This, ref);=0A =0A     if(ref=3D=3D0) {=0A+        /* If we ha=
ve successfully created an own render target */=0A+        if(This->buffer!=
=3DThis->target && This->buffer) IUnknown_Release(This->buffer);=0A+       =
 if(This->stencil) IUnknown_Release(This->stencil);=0A+        if(This->sta=
teblock) IUnknown_Release(This->stateblock);=0A+        IUnknown_Release(Th=
is->device);=0A         HeapFree(GetProcessHeap(), 0, This);=0A     }=0A   =
  return ref;=0A@@ -116,10 +121,97 @@ static HRESULT WINAPI ID3DXRenderToSu=
rfaceImpl_GetDesc(LPD3DXRENDERTOSURFACE ifa=0A     return D3D_OK;=0A }=0A =
=0A+ /************************************************************=0A+   * =
         ID3DXRenderToSurfaceImpl_BeginScene=0A+   *=0A+   * Saves the old =
viewport, render target and stencil buffer=0A+   * and sets the new ones. I=
f the given surface doesn't=0A+   * support being a render target we create=
 a new one.=0A+   * This function creates an own stencil buffer on first=0A=
+   * call if it was specified in D3DXCreateRenderToSurface=0A+   *=0A+   *=
 PARAMS=0A+   *   iface     [I]  RTS object=0A+   *   surface   [I]  pointe=
r to the surface we'll draw onto=0A+   *   viewport  [I]  pointer to the ne=
w viewport=0A+   *=0A+   * RETURNS=0A+   *   Success: D3D_OK=0A+   *   Fail=
ure: D3DERR_INVALIDCALL=0A+   *            D3DERR_OUTOFVIDEOMEMORY=0A+   * =
           D3DXERR_INVALIDDATA=0A+   *            E_OUTOFMEMORY=0A+   *=0A+=
   */=0A static HRESULT WINAPI ID3DXRenderToSurfaceImpl_BeginScene(LPD3DXRE=
NDERTOSURFACE iface, LPDIRECT3DSURFACE9 surface, CONST D3DVIEWPORT9 *viewpo=
rt)=0A {=0A     ID3DXRenderToSurfaceImpl *This=3D(ID3DXRenderToSurfaceImpl*=
)iface;=0A-    FIXME("(%p): stub\n", This);=0A+    D3DSURFACE_DESC surfdesc=
;=0A+    D3DVIEWPORT9 vpbuf;=0A+    HRESULT hr;=0A+=0A+    TRACE("(%p): rel=
ay\n", This);=0A+=0A+    if(surface=3D=3DNULL) return D3DERR_INVALIDCALL;=
=0A+=0A+    IDirect3DSurface9_GetDesc(surface, &surfdesc);=0A+=0A+    /* Ch=
eck if the surface is valid */=0A+    if(surfdesc.Width!=3DThis->desc.Width=
 || surfdesc.Height!=3DThis->desc.Height || surfdesc.Format!=3DThis->desc.F=
ormat)=0A+        return D3DERR_INVALIDCALL;=0A+=0A+    /* if the surface c=
hanged (this is always true on first BeginScene) */=0A+    if(This->target!=
=3Dsurface) {=0A+        /* If the surface is not compatible with our RTS o=
bject create an own render target*/=0A+        if(!(surfdesc.Usage & D3DUSA=
GE_RENDERTARGET)) {=0A+            if(FAILED(hr=3DIDirect3DDevice9_CreateRe=
nderTarget(This->device, This->desc.Width, This->desc.Height, This->desc.Fo=
rmat,=0A+                                                D3DMULTISAMPLE_NON=
E, 0, FALSE, &This->buffer, NULL))) return hr;=0A+        } else { /* else =
use the given surface */=0A+            This->buffer=3Dsurface;=0A+        =
}=0A+        /* Only create a stencil buffer if it's supported by the surfa=
ce */=0A+        if(This->desc.DepthStencil)=0A+            if(FAILED(hr=3D=
IDirect3DDevice9_CreateDepthStencilSurface(This->device, This->desc.Width, =
This->desc.Height,=0A+                                                     =
               This->desc.DepthStencilFormat, D3DMULTISAMPLE_NONE,=0A+     =
                                                               0, FALSE, &T=
his->stencil, NULL))) return hr;=0A+=0A+        /* Save the viewport */=0A+=
        if(FAILED(hr=3DIDirect3DDevice9_BeginStateBlock(This->device))) ret=
urn hr;=0A+        IDirect3DDevice9_SetViewport(This->device, &vpbuf);=0A+ =
       IDirect3DDevice9_EndStateBlock(This->device, &This->stateblock);=0A+=
    }=0A+    /* store a pointer to the surface */=0A+    /* NOTE: If the su=
rface has been created with D3DUSAGE_RENDERTARGET This->buffer and This->ta=
rget=0A+             both point to the same surface. This way we can later =
in EndScene check if the surface=0A+             was used as render target.=
 */=0A+    This->target=3Dsurface;=0A+=0A+    if(viewport=3D=3DNULL) {=0A+ =
       /* Use a default viewport */=0A+        vpbuf.X=3D0;=0A+        vpbu=
f.Y=3D0;=0A+        vpbuf.Width=3DThis->desc.Width;=0A+        vpbuf.Height=
=3DThis->desc.Height;=0A+        vpbuf.MinZ=3D0.0f;=0A+        vpbuf.MaxZ=
=3D1.0f;=0A+    } else {=0A+        /* Use the given viewport */=0A+       =
 memcpy(&vpbuf, viewport, sizeof(D3DVIEWPORT9));=0A+    }=0A+=0A+    /* sto=
re previous state */=0A+    IDirect3DStateBlock9_Capture(This->stateblock);=
=0A+    IDirect3DDevice9_GetRenderTarget(This->device, 0, &This->oldtarget)=
;=0A+    IDirect3DDevice9_GetDepthStencilSurface(This->device, &This->oldst=
encil);=0A+=0A+    /* prepare offscreen rendering */=0A+    IDirect3DDevice=
9_SetDepthStencilSurface(This->device, This->stencil);=0A+    IDirect3DDevi=
ce9_SetRenderTarget(This->device, 0, This->buffer);=0A+    IDirect3DDevice9=
_SetViewport(This->device, &vpbuf);=0A+    IDirect3DDevice9_BeginScene(This=
->device);=0A+=0A+    IDirect3DSurface9_AddRef(This->buffer);=0A+=0A     re=
turn D3D_OK;=0A }=0A =0A-- =0A1.5.3.7=0A=0A

--be2daac3d92a4928cc1a87b06a454c05c--



More information about the wine-patches mailing list