d3d: Remove AddRef from IWineD3DDevice_GetBackBuffer.
[wine.git] / dlls / d3d9 / device.c
blob8ed7b8d30458d36500692ee2b9fe9495dffb7e12
1 /*
2 * IDirect3DDevice9 implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Copyright 2002-2005 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "d3d9_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
29 /* IDirect3D IUnknown parts follow: */
30 static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9 iface, REFIID riid, LPVOID* ppobj) {
31 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
33 if (IsEqualGUID(riid, &IID_IUnknown)
34 || IsEqualGUID(riid, &IID_IDirect3DDevice9)) {
35 IUnknown_AddRef(iface);
36 *ppobj = This;
37 return S_OK;
40 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
41 *ppobj = NULL;
42 return E_NOINTERFACE;
45 static ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9 iface) {
46 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
47 ULONG ref = InterlockedIncrement(&This->ref);
49 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
51 return ref;
54 static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface) {
55 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
56 ULONG ref = InterlockedDecrement(&This->ref);
58 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
60 if (ref == 0) {
61 IWineD3DDevice_Uninit3D(This->WineD3DDevice);
62 IWineD3DDevice_Release(This->WineD3DDevice);
63 HeapFree(GetProcessHeap(), 0, This);
65 return ref;
68 /* IDirect3DDevice Interface follow: */
69 static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface) {
70 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
72 TRACE("(%p) : Relay\n", This);
73 return IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
76 static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface) {
77 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
79 TRACE("(%p) Relay\n", This);
80 return IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
83 static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9 iface) {
84 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
86 TRACE("(%p) : Relay\n", This);
87 return IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
90 HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9) {
91 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
92 HRESULT hr = D3D_OK;
93 IWineD3D* pWineD3D;
95 TRACE("(%p) Relay\n", This);
97 if (NULL == ppD3D9) {
98 return D3DERR_INVALIDCALL;
100 hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
101 if (hr == D3D_OK && pWineD3D != NULL)
103 IWineD3DResource_GetParent((IWineD3DResource *)pWineD3D,(IUnknown **)ppD3D9);
104 } else {
105 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
106 *ppD3D9 = NULL;
108 TRACE("(%p) returning %p\n", This, *ppD3D9);
109 return hr;
112 static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps) {
113 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
114 HRESULT hrc = D3D_OK;
115 WINED3DCAPS *pWineCaps;
117 TRACE("(%p) : Relay pCaps %p\n", This, pCaps);
118 if(NULL == pCaps){
119 return D3DERR_INVALIDCALL;
121 pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
122 if(pWineCaps == NULL){
123 return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
126 D3D9CAPSTOWINECAPS(pCaps, pWineCaps)
127 hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
128 HeapFree(GetProcessHeap(), 0, pWineCaps);
129 TRACE("Returning %p %p\n", This, pCaps);
130 return hrc;
133 static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) {
134 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
135 TRACE("(%p) Relay\n", This);
136 return IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
139 static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
140 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
141 TRACE("(%p) Relay\n", This);
142 return IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
145 static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
146 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
147 IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pCursorBitmap;
148 TRACE("(%p) Relay\n", This);
149 if(!pCursorBitmap) {
150 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
151 return WINED3DERR_INVALIDCALL;
153 return IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,(IWineD3DSurface*)pSurface->wineD3DSurface);
156 static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
157 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
158 TRACE("(%p) Relay\n", This);
159 return IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
162 static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9 iface, BOOL bShow) {
163 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
164 TRACE("(%p) Relay\n", This);
166 return IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
169 static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
170 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
171 WINED3DPRESENT_PARAMETERS localParameters;
172 TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
174 localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
175 localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
176 localParameters.BackBufferFormat = (WINED3DFORMAT *)&pPresentationParameters->BackBufferFormat;
177 localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
178 localParameters.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pPresentationParameters->MultiSampleType;
179 localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality;
180 localParameters.SwapEffect = (WINED3DSWAPEFFECT *) &pPresentationParameters->SwapEffect;
181 localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
182 localParameters.Windowed = &pPresentationParameters->Windowed;
183 localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
184 localParameters.AutoDepthStencilFormat = (WINED3DFORMAT *)&pPresentationParameters->AutoDepthStencilFormat;
185 localParameters.Flags = &pPresentationParameters->Flags;
186 localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
187 localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval;
188 return IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
191 static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA*
192 pDirtyRegion) {
193 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
194 TRACE("(%p) Relay\n", This);
195 return IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
198 static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 ** ppBackBuffer) {
199 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
200 IWineD3DSurface *retSurface = NULL;
201 HRESULT rc = D3D_OK;
203 TRACE("(%p) Relay\n", This);
205 rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, (IWineD3DSurface **)&retSurface);
206 if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
207 IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
209 return rc;
211 static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
212 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
213 TRACE("(%p) Relay\n", This);
215 return IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
218 static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface, BOOL bEnableDialogs) {
219 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
220 TRACE("(%p) Relay\n", This);
222 return IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
225 static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
227 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
228 TRACE("(%p) Relay\n", This);
230 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
231 return IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, iSwapChain, Flags, (CONST WINED3DGAMMARAMP *)pRamp);
234 static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
235 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
236 TRACE("(%p) Relay\n", This);
238 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
239 return IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *) pRamp);
243 static HRESULT WINAPI IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,D3DRESOURCETYPE Type, UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,HANDLE* pSharedHandle ) {
244 HRESULT hrc;
245 IDirect3DSurface9Impl *object;
246 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
247 TRACE("(%p) Relay\n", This);
248 if(MultisampleQuality < 0) {
249 FIXME("MultisampleQuality out of range %d, substituting 0\n", MultisampleQuality);
250 /*FIXME: Find out what windows does with a MultisampleQuality < 0 */
251 MultisampleQuality=0;
254 if(MultisampleQuality > 0){
255 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality);
257 MultisampleQuality
258 [in] Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces, and the MultiSample type must all match.
261 MultisampleQuality=0;
263 /*FIXME: Check MAX bounds of MultisampleQuality*/
265 /* Allocate the storage for the device */
266 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
267 if (NULL == object) {
268 FIXME("Allocation of memory failed\n");
269 return D3DERR_OUTOFVIDEOMEMORY;
272 object->lpVtbl = &Direct3DSurface9_Vtbl;
273 object->ref = 1;
275 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
277 hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, Format, Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL) Pool,MultiSample,MultisampleQuality,pSharedHandle,SURFACE_OPENGL,(IUnknown *)object);
279 if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
281 /* free up object */
282 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
283 HeapFree(GetProcessHeap(), 0, object);
284 } else {
285 IUnknown_AddRef(iface);
286 object->parentDevice = iface;
287 TRACE("(%p) : Created surface %p\n", This, object);
288 *ppSurface = (LPDIRECT3DSURFACE9) object;
290 return hrc;
295 static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
296 D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
297 DWORD MultisampleQuality, BOOL Lockable,
298 IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
299 TRACE("Relay\n");
300 /* Is this correct? */
301 return IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,Lockable,FALSE/*Discard*/, 0/*Level*/, ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_RENDERTARGET,D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
306 static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
307 D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
308 DWORD MultisampleQuality, BOOL Discard,
309 IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
310 TRACE("Relay\n");
311 return IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/* Lockable */,Discard, 0/* Level */
312 ,ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_DEPTHSTENCIL,
313 D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
317 static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) {
318 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
319 TRACE("(%p) Relay\n" , This);
320 return IWineD3DDevice_UpdateSurface(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestinationSurface)->wineD3DSurface, pDestPoint);
323 static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9 iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
324 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
325 TRACE("(%p) Relay\n" , This);
326 return IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture9Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture9Impl *)pDestinationTexture)->wineD3DBaseTexture);
329 /* This isn't in MSDN!
330 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pDestSurface) {
331 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
332 FIXME("(%p) : stub\n", This);
333 return D3D_OK;
337 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
338 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
339 IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget;
340 IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
341 TRACE("(%p) Relay\n" , This);
342 return IWineD3DDevice_GetRenderTargetData(This->WineD3DDevice, renderTarget->wineD3DSurface, destSurface->wineD3DSurface);
345 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
346 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
347 IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
348 TRACE("(%p) Relay\n" , This);
349 return IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wineD3DSurface);
352 static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
353 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
354 TRACE("(%p) Relay\n" , This);
355 return IWineD3DDevice_StretchRect(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface, pDestRect, (WINED3DTEXTUREFILTERTYPE) Filter);
358 static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
359 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
360 IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
361 TRACE("(%p) Relay\n" , This);
363 /* Note: D3DRECT is compatible with WINED3DRECT */
364 return IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, (CONST WINED3DRECT*)pRect, color);
367 static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
368 TRACE("Relay\n");
369 if(Pool == D3DPOOL_MANAGED ){
370 FIXME("Attempting to create a managed offscreen plain surface\n");
371 return D3DERR_INVALIDCALL;
373 /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface.
375 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
376 but then...
377 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
378 Why, their always lockable?
379 should I change the usage to dynamic?
381 return IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/*Loackable*/,FALSE/*Discard*/,0/*Level*/ , ppSurface,D3DRTYPE_SURFACE, 0/*Usage (undefined/none)*/,(WINED3DPOOL) Pool,D3DMULTISAMPLE_NONE,0/*MultisampleQuality*/,pSharedHandle);
384 /* TODO: move to wineD3D */
385 static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
386 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
387 IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
388 TRACE("(%p) Relay\n" , This);
389 return IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, RenderTargetIndex, pSurface ? (IWineD3DSurface*)pSurface->wineD3DSurface : NULL);
392 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
393 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
394 HRESULT hr = D3D_OK;
395 IWineD3DSurface *pRenderTarget;
397 TRACE("(%p) Relay\n" , This);
399 if (ppRenderTarget == NULL) {
400 return D3DERR_INVALIDCALL;
402 hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
404 if (hr == D3D_OK && pRenderTarget != NULL) {
405 IWineD3DResource_GetParent((IWineD3DResource *)pRenderTarget,(IUnknown**)ppRenderTarget);
406 IWineD3DResource_Release((IWineD3DResource *)pRenderTarget);
407 } else {
408 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
409 *ppRenderTarget = NULL;
411 return hr;
414 static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
415 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
416 IDirect3DSurface9Impl *pSurface;
418 TRACE("(%p) Relay\n" , This);
420 pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
421 return IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice,NULL==pSurface?NULL:(IWineD3DSurface*)pSurface->wineD3DSurface);
424 static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9 **ppZStencilSurface) {
425 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
426 HRESULT hr = D3D_OK;
427 IWineD3DSurface *pZStencilSurface;
429 TRACE("(%p) Relay\n" , This);
430 if(ppZStencilSurface == NULL){
431 return D3DERR_INVALIDCALL;
434 hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
435 if(hr == D3D_OK && pZStencilSurface != NULL){
436 IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface);
437 IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface);
438 }else{
439 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
440 *ppZStencilSurface = NULL;
442 return D3D_OK;
445 static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9 iface) {
446 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
447 TRACE("(%p) Relay\n" , This);
448 return IWineD3DDevice_BeginScene(This->WineD3DDevice);
451 static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9 iface) {
452 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
453 TRACE("(%p) Relay\n" , This);
454 return IWineD3DDevice_EndScene(This->WineD3DDevice);
458 static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
459 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
460 TRACE("(%p) Relay\n" , This);
462 /* Note: D3DRECT is compatible with WINED3DRECT */
463 return IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
466 static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
467 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
468 TRACE("(%p) Relay\n" , This);
470 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
471 return IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
474 static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
475 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
476 TRACE("(%p) Relay\n" , This);
478 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
479 return IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
482 static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
483 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
484 TRACE("(%p) Relay\n" , This);
486 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
487 return IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
490 static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport) {
491 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
492 TRACE("(%p) Relay\n" , This);
494 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
495 return IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
498 static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVIEWPORT9* pViewport) {
499 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
500 TRACE("(%p) Relay\n" , This);
502 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
503 return IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
506 static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial) {
507 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
508 TRACE("(%p) Relay\n" , This);
510 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
511 return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
514 static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial) {
515 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
516 TRACE("(%p) Relay\n" , This);
518 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
519 return IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
522 static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight) {
523 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
524 TRACE("(%p) Relay\n" , This);
526 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
527 return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
530 static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight) {
531 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
532 TRACE("(%p) Relay\n" , This);
534 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
535 return IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
538 static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL Enable) {
539 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
540 TRACE("(%p) Relay\n" , This);
541 return IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
544 static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL* pEnable) {
545 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
546 TRACE("(%p) Relay\n" , This);
547 return IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
550 static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST float* pPlane) {
551 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
552 TRACE("(%p) Relay\n" , This);
553 return IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
556 static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, float* pPlane) {
557 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
558 TRACE("(%p) Relay\n" , This);
559 return IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
562 static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value) {
563 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
564 TRACE("(%p) Relay\n" , This);
565 return IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
568 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD* pValue) {
569 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
570 TRACE("(%p) Relay\n" , This);
571 return IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
574 static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus) {
575 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
576 TRACE("(%p) Relay\n" , This);
577 return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
580 static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3DCLIPSTATUS9* pClipStatus) {
581 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
582 TRACE("(%p) Relay\n" , This);
583 return IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
586 static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9 **ppTexture) {
587 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
588 IWineD3DBaseTexture *retTexture = NULL;
589 HRESULT rc = D3D_OK;
591 TRACE("(%p) Relay\n" , This);
593 if(ppTexture == NULL){
594 return D3DERR_INVALIDCALL;
597 rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, (IWineD3DBaseTexture **)&retTexture);
598 if (rc == D3D_OK && NULL != retTexture) {
599 IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
600 IWineD3DBaseTexture_Release(retTexture);
601 }else{
602 FIXME("Call to get texture (%d) failed (%p)\n", Stage, retTexture);
603 *ppTexture = NULL;
605 return rc;
608 static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) {
609 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
610 TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
611 return IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
612 pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture);
615 static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
616 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
617 TRACE("(%p) Relay\n" , This);
618 return IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
621 static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
622 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
623 TRACE("(%p) Relay\n" , This);
624 return IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
627 static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
628 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
629 TRACE("(%p) Relay\n" , This);
630 return IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Sampler, Type, pValue);
633 static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
634 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
635 TRACE("(%p) Relay\n" , This);
636 return IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Sampler, Type, Value);
639 static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9 iface, DWORD* pNumPasses) {
640 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
641 TRACE("(%p) Relay\n" , This);
642 return IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
645 static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
646 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
647 TRACE("(%p) Relay\n" , This);
648 return IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
651 static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
652 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
653 TRACE("(%p) Relay\n" , This);
654 return IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
657 static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber) {
658 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
659 TRACE("(%p) Relay\n" , This);
660 return IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
663 static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT* PaletteNumber) {
664 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
665 TRACE("(%p) Relay\n" , This);
666 return IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
669 static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9 iface, CONST RECT* pRect) {
670 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
671 TRACE("(%p) Relay\n" , This);
672 return IWineD3DDevice_SetScissorRect(This->WineD3DDevice, pRect);
675 static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9 iface, RECT* pRect) {
676 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
677 TRACE("(%p) Relay\n" , This);
678 return IWineD3DDevice_GetScissorRect(This->WineD3DDevice, pRect);
681 static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface, BOOL bSoftware) {
682 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
683 TRACE("(%p) Relay\n" , This);
684 return IWineD3DDevice_SetSoftwareVertexProcessing(This->WineD3DDevice, bSoftware);
687 static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface) {
688 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
689 TRACE("(%p) Relay\n" , This);
690 return IWineD3DDevice_GetSoftwareVertexProcessing(This->WineD3DDevice);
693 static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9 iface, float nSegments) {
694 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
695 TRACE("(%p) Relay\n" , This);
696 return IWineD3DDevice_SetNPatchMode(This->WineD3DDevice, nSegments);
699 static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9 iface) {
700 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
701 TRACE("(%p) Relay\n" , This);
702 return IWineD3DDevice_GetNPatchMode(This->WineD3DDevice);
705 static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
706 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
707 TRACE("(%p) Relay\n" , This);
708 return IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount);
711 static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType,
712 INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
713 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
714 TRACE("(%p) Relay\n" , This);
715 return IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
718 static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
719 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
720 TRACE("(%p) Relay\n" , This);
721 return IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
724 static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex,
725 UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData,
726 D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
727 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
728 TRACE("(%p) Relay\n" , This);
729 return IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
730 pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
733 static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9 iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) {
734 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
735 TRACE("(%p) Relay\n" , This);
736 return IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer9Impl *)pDestBuffer)->wineD3DVertexBuffer, ((IDirect3DVertexBuffer9Impl *)pVertexDecl)->wineD3DVertexBuffer, Flags);
739 HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface, DWORD FVF) {
740 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
741 TRACE("(%p) Relay\n" , This);
743 if (0 != FVF) {
744 HRESULT hr;
745 D3DVERTEXELEMENT9* elements = NULL;
746 IDirect3DVertexDeclaration9* pDecl = NULL;
748 hr = vdecl_convert_fvf(FVF, &elements);
749 if (hr != S_OK) goto exit;
751 hr = IDirect3DDevice9Impl_CreateVertexDeclaration(iface, elements, &pDecl);
752 if (hr != S_OK) goto exit;
754 hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, pDecl);
755 if (hr != S_OK) goto exit;
756 pDecl = NULL;
758 exit:
759 HeapFree(GetProcessHeap(), 0, elements);
760 if (pDecl) IUnknown_Release(pDecl);
761 if (hr != S_OK) return hr;
764 return IWineD3DDevice_SetFVF(This->WineD3DDevice, FVF);
767 HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface, DWORD* pFVF) {
768 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
769 TRACE("(%p) Relay\n" , This);
770 return IWineD3DDevice_GetFVF(This->WineD3DDevice, pFVF);
773 HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
774 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
775 TRACE("(%p) Relay\n" , This);
776 return IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
777 pStreamData==NULL ? NULL:((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer,
778 OffsetInBytes, Stride);
781 HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) {
782 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
783 IWineD3DVertexBuffer *retStream = NULL;
784 HRESULT rc = D3D_OK;
786 TRACE("(%p) Relay\n" , This);
788 if(pStream == NULL){
789 return D3DERR_INVALIDCALL;
792 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, OffsetInBytes, pStride);
793 if (rc == D3D_OK && NULL != retStream) {
794 IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream);
795 IWineD3DVertexBuffer_Release(retStream);
796 }else{
797 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes, pStride);
798 *pStream = NULL;
800 return rc;
803 static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT Divider) {
804 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
805 TRACE("(%p) Relay\n" , This);
806 IWineD3DDevice_SetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
807 return D3D_OK;
810 static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT* Divider) {
811 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
812 TRACE("(%p) Relay\n" , This);
813 return IWineD3DDevice_GetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
814 return D3D_OK;
817 static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9* pIndexData) {
818 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
819 TRACE("(%p) Relay\n", This);
820 return IWineD3DDevice_SetIndices(This->WineD3DDevice,
821 pIndexData==NULL ? NULL:((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer,
825 static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9 **ppIndexData) {
826 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
827 IWineD3DIndexBuffer *retIndexData = NULL;
828 HRESULT rc = D3D_OK;
829 UINT tmp;
831 TRACE("(%p) Relay\n", This);
833 if(ppIndexData == NULL){
834 return D3DERR_INVALIDCALL;
837 rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData, &tmp);
838 if (rc == D3D_OK && NULL != retIndexData) {
839 IWineD3DVertexBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
840 IWineD3DVertexBuffer_Release(retIndexData);
841 }else{
842 if(rc != D3D_OK) FIXME("Call to GetIndices failed\n");
843 *ppIndexData = NULL;
845 return rc;
848 static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
849 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
850 TRACE("(%p) Relay\n", This);
851 return IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
853 /*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawTriPatch.asp*/
854 static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
855 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
856 TRACE("(%p) Relay\n", This);
857 return IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
860 static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9 iface, UINT Handle) {
861 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
862 TRACE("(%p) Relay\n", This);
863 return IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
866 const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl =
868 /* IUnknown */
869 IDirect3DDevice9Impl_QueryInterface,
870 IDirect3DDevice9Impl_AddRef,
871 IDirect3DDevice9Impl_Release,
872 /* IDirect3DDevice9 */
873 IDirect3DDevice9Impl_TestCooperativeLevel,
874 IDirect3DDevice9Impl_GetAvailableTextureMem,
875 IDirect3DDevice9Impl_EvictManagedResources,
876 IDirect3DDevice9Impl_GetDirect3D,
877 IDirect3DDevice9Impl_GetDeviceCaps,
878 IDirect3DDevice9Impl_GetDisplayMode,
879 IDirect3DDevice9Impl_GetCreationParameters,
880 IDirect3DDevice9Impl_SetCursorProperties,
881 IDirect3DDevice9Impl_SetCursorPosition,
882 IDirect3DDevice9Impl_ShowCursor,
883 IDirect3DDevice9Impl_CreateAdditionalSwapChain,
884 IDirect3DDevice9Impl_GetSwapChain,
885 IDirect3DDevice9Impl_GetNumberOfSwapChains,
886 IDirect3DDevice9Impl_Reset,
887 IDirect3DDevice9Impl_Present,
888 IDirect3DDevice9Impl_GetBackBuffer,
889 IDirect3DDevice9Impl_GetRasterStatus,
890 IDirect3DDevice9Impl_SetDialogBoxMode,
891 IDirect3DDevice9Impl_SetGammaRamp,
892 IDirect3DDevice9Impl_GetGammaRamp,
893 IDirect3DDevice9Impl_CreateTexture,
894 IDirect3DDevice9Impl_CreateVolumeTexture,
895 IDirect3DDevice9Impl_CreateCubeTexture,
896 IDirect3DDevice9Impl_CreateVertexBuffer,
897 IDirect3DDevice9Impl_CreateIndexBuffer,
898 IDirect3DDevice9Impl_CreateRenderTarget,
899 IDirect3DDevice9Impl_CreateDepthStencilSurface,
900 IDirect3DDevice9Impl_UpdateSurface,
901 IDirect3DDevice9Impl_UpdateTexture,
902 IDirect3DDevice9Impl_GetRenderTargetData,
903 IDirect3DDevice9Impl_GetFrontBufferData,
904 IDirect3DDevice9Impl_StretchRect,
905 IDirect3DDevice9Impl_ColorFill,
906 IDirect3DDevice9Impl_CreateOffscreenPlainSurface,
907 IDirect3DDevice9Impl_SetRenderTarget,
908 IDirect3DDevice9Impl_GetRenderTarget,
909 IDirect3DDevice9Impl_SetDepthStencilSurface,
910 IDirect3DDevice9Impl_GetDepthStencilSurface,
911 IDirect3DDevice9Impl_BeginScene,
912 IDirect3DDevice9Impl_EndScene,
913 IDirect3DDevice9Impl_Clear,
914 IDirect3DDevice9Impl_SetTransform,
915 IDirect3DDevice9Impl_GetTransform,
916 IDirect3DDevice9Impl_MultiplyTransform,
917 IDirect3DDevice9Impl_SetViewport,
918 IDirect3DDevice9Impl_GetViewport,
919 IDirect3DDevice9Impl_SetMaterial,
920 IDirect3DDevice9Impl_GetMaterial,
921 IDirect3DDevice9Impl_SetLight,
922 IDirect3DDevice9Impl_GetLight,
923 IDirect3DDevice9Impl_LightEnable,
924 IDirect3DDevice9Impl_GetLightEnable,
925 IDirect3DDevice9Impl_SetClipPlane,
926 IDirect3DDevice9Impl_GetClipPlane,
927 IDirect3DDevice9Impl_SetRenderState,
928 IDirect3DDevice9Impl_GetRenderState,
929 IDirect3DDevice9Impl_CreateStateBlock,
930 IDirect3DDevice9Impl_BeginStateBlock,
931 IDirect3DDevice9Impl_EndStateBlock,
932 IDirect3DDevice9Impl_SetClipStatus,
933 IDirect3DDevice9Impl_GetClipStatus,
934 IDirect3DDevice9Impl_GetTexture,
935 IDirect3DDevice9Impl_SetTexture,
936 IDirect3DDevice9Impl_GetTextureStageState,
937 IDirect3DDevice9Impl_SetTextureStageState,
938 IDirect3DDevice9Impl_GetSamplerState,
939 IDirect3DDevice9Impl_SetSamplerState,
940 IDirect3DDevice9Impl_ValidateDevice,
941 IDirect3DDevice9Impl_SetPaletteEntries,
942 IDirect3DDevice9Impl_GetPaletteEntries,
943 IDirect3DDevice9Impl_SetCurrentTexturePalette,
944 IDirect3DDevice9Impl_GetCurrentTexturePalette,
945 IDirect3DDevice9Impl_SetScissorRect,
946 IDirect3DDevice9Impl_GetScissorRect,
947 IDirect3DDevice9Impl_SetSoftwareVertexProcessing,
948 IDirect3DDevice9Impl_GetSoftwareVertexProcessing,
949 IDirect3DDevice9Impl_SetNPatchMode,
950 IDirect3DDevice9Impl_GetNPatchMode,
951 IDirect3DDevice9Impl_DrawPrimitive,
952 IDirect3DDevice9Impl_DrawIndexedPrimitive,
953 IDirect3DDevice9Impl_DrawPrimitiveUP,
954 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP,
955 IDirect3DDevice9Impl_ProcessVertices,
956 IDirect3DDevice9Impl_CreateVertexDeclaration,
957 IDirect3DDevice9Impl_SetVertexDeclaration,
958 IDirect3DDevice9Impl_GetVertexDeclaration,
959 IDirect3DDevice9Impl_SetFVF,
960 IDirect3DDevice9Impl_GetFVF,
961 IDirect3DDevice9Impl_CreateVertexShader,
962 IDirect3DDevice9Impl_SetVertexShader,
963 IDirect3DDevice9Impl_GetVertexShader,
964 IDirect3DDevice9Impl_SetVertexShaderConstantF,
965 IDirect3DDevice9Impl_GetVertexShaderConstantF,
966 IDirect3DDevice9Impl_SetVertexShaderConstantI,
967 IDirect3DDevice9Impl_GetVertexShaderConstantI,
968 IDirect3DDevice9Impl_SetVertexShaderConstantB,
969 IDirect3DDevice9Impl_GetVertexShaderConstantB,
970 IDirect3DDevice9Impl_SetStreamSource,
971 IDirect3DDevice9Impl_GetStreamSource,
972 IDirect3DDevice9Impl_SetStreamSourceFreq,
973 IDirect3DDevice9Impl_GetStreamSourceFreq,
974 IDirect3DDevice9Impl_SetIndices,
975 IDirect3DDevice9Impl_GetIndices,
976 IDirect3DDevice9Impl_CreatePixelShader,
977 IDirect3DDevice9Impl_SetPixelShader,
978 IDirect3DDevice9Impl_GetPixelShader,
979 IDirect3DDevice9Impl_SetPixelShaderConstantF,
980 IDirect3DDevice9Impl_GetPixelShaderConstantF,
981 IDirect3DDevice9Impl_SetPixelShaderConstantI,
982 IDirect3DDevice9Impl_GetPixelShaderConstantI,
983 IDirect3DDevice9Impl_SetPixelShaderConstantB,
984 IDirect3DDevice9Impl_GetPixelShaderConstantB,
985 IDirect3DDevice9Impl_DrawRectPatch,
986 IDirect3DDevice9Impl_DrawTriPatch,
987 IDirect3DDevice9Impl_DeletePatch,
988 IDirect3DDevice9Impl_CreateQuery
992 /* Internal function called back during the CreateDevice to create a render target */
993 HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
994 WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
995 IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
997 HRESULT res = D3D_OK;
998 IDirect3DSurface9Impl *d3dSurface = NULL;
999 BOOL Lockable = TRUE;
1001 if((Pool == D3DPOOL_DEFAULT && Usage != D3DUSAGE_DYNAMIC))
1002 Lockable = FALSE;
1004 TRACE("relay\n");
1005 res = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9 *)device, Width, Height, (D3DFORMAT)Format,
1006 Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface9 **)&d3dSurface, D3DRTYPE_SURFACE,
1007 Usage, (D3DPOOL) Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, pSharedHandle);
1009 if (SUCCEEDED(res)) {
1010 *ppSurface = d3dSurface->wineD3DSurface;
1011 IUnknown_Release(d3dSurface->parentDevice);
1012 d3dSurface->parentDevice = NULL;
1013 } else {
1014 FIXME("(%p) IDirect3DDevice9_CreateSurface failed\n", device);
1016 return res;