2 * Copyright (C) 2012 Józef Kucia
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/debug.h"
21 #include "d3dx9_36_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
25 struct render_to_surface
27 ID3DXRenderToSurface ID3DXRenderToSurface_iface
;
30 IDirect3DDevice9
*device
;
34 static inline struct render_to_surface
*impl_from_ID3DXRenderToSurface(ID3DXRenderToSurface
*iface
)
36 return CONTAINING_RECORD(iface
, struct render_to_surface
, ID3DXRenderToSurface_iface
);
39 static HRESULT WINAPI
D3DXRenderToSurface_QueryInterface(ID3DXRenderToSurface
*iface
,
43 TRACE("iface %p, riid %s, out %p\n", iface
, debugstr_guid(riid
), out
);
45 if (IsEqualGUID(riid
, &IID_ID3DXRenderToSurface
)
46 || IsEqualGUID(riid
, &IID_IUnknown
))
48 IUnknown_AddRef(iface
);
53 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
59 static ULONG WINAPI
D3DXRenderToSurface_AddRef(ID3DXRenderToSurface
*iface
)
61 struct render_to_surface
*render
= impl_from_ID3DXRenderToSurface(iface
);
62 ULONG ref
= InterlockedIncrement(&render
->ref
);
64 TRACE("%p increasing refcount to %u\n", iface
, ref
);
69 static ULONG WINAPI
D3DXRenderToSurface_Release(ID3DXRenderToSurface
*iface
)
71 struct render_to_surface
*render
= impl_from_ID3DXRenderToSurface(iface
);
72 ULONG ref
= InterlockedDecrement(&render
->ref
);
74 TRACE("%p decreasing refcount to %u\n", iface
, ref
);
78 IDirect3DDevice9_Release(render
->device
);
79 HeapFree(GetProcessHeap(), 0, render
);
85 static HRESULT WINAPI
D3DXRenderToSurface_GetDevice(ID3DXRenderToSurface
*iface
,
86 IDirect3DDevice9
**device
)
88 struct render_to_surface
*render
= impl_from_ID3DXRenderToSurface(iface
);
90 TRACE("(%p)->(%p)\n", iface
, device
);
92 if (!device
) return D3DERR_INVALIDCALL
;
94 IDirect3DDevice9_AddRef(render
->device
);
95 *device
= render
->device
;
99 static HRESULT WINAPI
D3DXRenderToSurface_GetDesc(ID3DXRenderToSurface
*iface
,
102 struct render_to_surface
*render
= impl_from_ID3DXRenderToSurface(iface
);
104 TRACE("(%p)->(%p)\n", iface
, desc
);
106 if (!desc
) return D3DERR_INVALIDCALL
;
108 *desc
= render
->desc
;
112 static HRESULT WINAPI
D3DXRenderToSurface_BeginScene(ID3DXRenderToSurface
*iface
,
113 IDirect3DSurface9
*surface
,
114 const D3DVIEWPORT9
*viewport
)
116 FIXME("(%p)->(%p, %p): stub\n", iface
, surface
, viewport
);
120 static HRESULT WINAPI
D3DXRenderToSurface_EndScene(ID3DXRenderToSurface
*iface
,
123 FIXME("(%p)->(%#x): stub\n", iface
, mip_filter
);
127 static HRESULT WINAPI
D3DXRenderToSurface_OnLostDevice(ID3DXRenderToSurface
*iface
)
129 FIXME("(%p)->(): stub\n", iface
);
133 static HRESULT WINAPI
D3DXRenderToSurface_OnResetDevice(ID3DXRenderToSurface
*iface
)
135 FIXME("(%p)->(): stub\n", iface
);
139 static const ID3DXRenderToSurfaceVtbl d3dx_render_to_surface_vtbl
=
141 /* IUnknown methods */
142 D3DXRenderToSurface_QueryInterface
,
143 D3DXRenderToSurface_AddRef
,
144 D3DXRenderToSurface_Release
,
145 /* ID3DXRenderToSurface methods */
146 D3DXRenderToSurface_GetDevice
,
147 D3DXRenderToSurface_GetDesc
,
148 D3DXRenderToSurface_BeginScene
,
149 D3DXRenderToSurface_EndScene
,
150 D3DXRenderToSurface_OnLostDevice
,
151 D3DXRenderToSurface_OnResetDevice
154 HRESULT WINAPI
D3DXCreateRenderToSurface(IDirect3DDevice9
*device
,
159 D3DFORMAT depth_stencil_format
,
160 ID3DXRenderToSurface
**out
)
162 struct render_to_surface
*render
;
164 TRACE("(%p, %u, %u, %#x, %d, %#x, %p)\n", device
, width
, height
, format
,
165 depth_stencil
, depth_stencil_format
, out
);
167 if (!device
|| !out
) return D3DERR_INVALIDCALL
;
169 render
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct render_to_surface
));
170 if (!render
) return E_OUTOFMEMORY
;
172 render
->ID3DXRenderToSurface_iface
.lpVtbl
= &d3dx_render_to_surface_vtbl
;
175 IDirect3DDevice9_AddRef(device
);
176 render
->device
= device
;
178 render
->desc
.Width
= width
;
179 render
->desc
.Height
= height
;
180 render
->desc
.Format
= format
;
181 render
->desc
.DepthStencil
= depth_stencil
;
182 render
->desc
.DepthStencilFormat
= depth_stencil_format
;
184 *out
= &render
->ID3DXRenderToSurface_iface
;