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;
33 static inline struct render_to_surface *impl_from_ID3DXRenderToSurface(ID3DXRenderToSurface *iface)
35 return CONTAINING_RECORD(iface, struct render_to_surface, ID3DXRenderToSurface_iface);
38 static HRESULT WINAPI D3DXRenderToSurface_QueryInterface(ID3DXRenderToSurface *iface,
42 TRACE("iface %p, riid %s, out %p\n", iface, debugstr_guid(riid), out);
44 if (IsEqualGUID(riid, &IID_ID3DXRenderToSurface)
45 || IsEqualGUID(riid, &IID_IUnknown))
47 IUnknown_AddRef(iface);
52 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
58 static ULONG WINAPI D3DXRenderToSurface_AddRef(ID3DXRenderToSurface *iface)
60 struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface);
61 ULONG ref = InterlockedIncrement(&render->ref);
63 TRACE("%p increasing refcount to %u\n", iface, ref);
68 static ULONG WINAPI D3DXRenderToSurface_Release(ID3DXRenderToSurface *iface)
70 struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface);
71 ULONG ref = InterlockedDecrement(&render->ref);
73 TRACE("%p decreasing refcount to %u\n", iface, ref);
77 IDirect3DDevice9_Release(render->device);
78 HeapFree(GetProcessHeap(), 0, render);
84 static HRESULT WINAPI D3DXRenderToSurface_GetDevice(ID3DXRenderToSurface *iface,
85 IDirect3DDevice9 **device)
87 FIXME("(%p)->(%p): stub\n", iface, device);
91 static HRESULT WINAPI D3DXRenderToSurface_GetDesc(ID3DXRenderToSurface *iface,
94 FIXME("(%p)->(%p): stub\n", iface, desc);
98 static HRESULT WINAPI D3DXRenderToSurface_BeginScene(ID3DXRenderToSurface *iface,
99 IDirect3DSurface9 *surface,
100 const D3DVIEWPORT9 *viewport)
102 FIXME("(%p)->(%p, %p): stub\n", iface, surface, viewport);
106 static HRESULT WINAPI D3DXRenderToSurface_EndScene(ID3DXRenderToSurface *iface,
109 FIXME("(%p)->(%#x): stub\n", iface, mip_filter);
113 static HRESULT WINAPI D3DXRenderToSurface_OnLostDevice(ID3DXRenderToSurface *iface)
115 FIXME("(%p)->(): stub\n", iface);
119 static HRESULT WINAPI D3DXRenderToSurface_OnResetDevice(ID3DXRenderToSurface *iface)
121 FIXME("(%p)->(): stub\n", iface);
125 static const ID3DXRenderToSurfaceVtbl d3dx_render_to_surface_vtbl =
127 /* IUnknown methods */
128 D3DXRenderToSurface_QueryInterface,
129 D3DXRenderToSurface_AddRef,
130 D3DXRenderToSurface_Release,
131 /* ID3DXRenderToSurface methods */
132 D3DXRenderToSurface_GetDevice,
133 D3DXRenderToSurface_GetDesc,
134 D3DXRenderToSurface_BeginScene,
135 D3DXRenderToSurface_EndScene,
136 D3DXRenderToSurface_OnLostDevice,
137 D3DXRenderToSurface_OnResetDevice
140 HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
145 D3DFORMAT depth_stencil_format,
146 ID3DXRenderToSurface **out)
148 struct render_to_surface *render;
150 FIXME("(%p, %u, %u, %#x, %d, %#x, %p): semi-stub\n", device, width, height, format,
151 depth_stencil, depth_stencil_format, out);
153 if (!device || !out) return D3DERR_INVALIDCALL;
155 render = HeapAlloc(GetProcessHeap(), 0, sizeof(struct render_to_surface));
156 if (!render) return E_OUTOFMEMORY;
158 render->ID3DXRenderToSurface_iface.lpVtbl = &d3dx_render_to_surface_vtbl;
161 IDirect3DDevice9_AddRef(device);
162 render->device = device;
164 *out = &render->ID3DXRenderToSurface_iface;