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
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
);
40 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
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);
54 static ULONG WINAPI
IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface
) {
55 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
58 if (This
->inDestruction
) return 0;
59 ref
= InterlockedDecrement(&This
->ref
);
61 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
64 This
->inDestruction
= TRUE
;
65 IWineD3DDevice_Uninit3D(This
->WineD3DDevice
, D3D9CB_DestroyDepthStencilSurface
, D3D9CB_DestroySwapChain
);
66 IWineD3DDevice_Release(This
->WineD3DDevice
);
67 HeapFree(GetProcessHeap(), 0, This
);
72 /* IDirect3DDevice Interface follow: */
73 static HRESULT WINAPI
IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface
) {
74 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
76 TRACE("(%p) : Relay\n", This
);
77 return IWineD3DDevice_TestCooperativeLevel(This
->WineD3DDevice
);
80 static UINT WINAPI
IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface
) {
81 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
83 TRACE("(%p) Relay\n", This
);
84 return IWineD3DDevice_GetAvailableTextureMem(This
->WineD3DDevice
);
87 static HRESULT WINAPI
IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9 iface
) {
88 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
90 TRACE("(%p) : Relay\n", This
);
91 return IWineD3DDevice_EvictManagedResources(This
->WineD3DDevice
);
94 HRESULT WINAPI
IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface
, IDirect3D9
** ppD3D9
) {
95 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
99 TRACE("(%p) Relay\n", This
);
101 if (NULL
== ppD3D9
) {
102 return D3DERR_INVALIDCALL
;
104 hr
= IWineD3DDevice_GetDirect3D(This
->WineD3DDevice
, &pWineD3D
);
105 if (hr
== D3D_OK
&& pWineD3D
!= NULL
)
107 IWineD3D_GetParent(pWineD3D
,(IUnknown
**)ppD3D9
);
108 IWineD3D_Release(pWineD3D
);
110 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
113 TRACE("(%p) returning %p\n", This
, *ppD3D9
);
117 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface
, D3DCAPS9
* pCaps
) {
118 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
119 HRESULT hrc
= D3D_OK
;
120 WINED3DCAPS
*pWineCaps
;
122 TRACE("(%p) : Relay pCaps %p\n", This
, pCaps
);
124 return D3DERR_INVALIDCALL
;
126 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
127 if(pWineCaps
== NULL
){
128 return D3DERR_INVALIDCALL
; /* well this is what MSDN says to return */
131 D3D9CAPSTOWINECAPS(pCaps
, pWineCaps
)
132 hrc
= IWineD3DDevice_GetDeviceCaps(This
->WineD3DDevice
, pWineCaps
);
133 HeapFree(GetProcessHeap(), 0, pWineCaps
);
134 TRACE("Returning %p %p\n", This
, pCaps
);
138 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DDISPLAYMODE
* pMode
) {
139 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
140 TRACE("(%p) Relay\n", This
);
141 return IWineD3DDevice_GetDisplayMode(This
->WineD3DDevice
, iSwapChain
, (WINED3DDISPLAYMODE
*) pMode
);
144 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface
, D3DDEVICE_CREATION_PARAMETERS
*pParameters
) {
145 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
146 TRACE("(%p) Relay\n", This
);
147 return IWineD3DDevice_GetCreationParameters(This
->WineD3DDevice
, (WINED3DDEVICE_CREATION_PARAMETERS
*) pParameters
);
150 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface
, UINT XHotSpot
, UINT YHotSpot
, IDirect3DSurface9
* pCursorBitmap
) {
151 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
152 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pCursorBitmap
;
153 TRACE("(%p) Relay\n", This
);
155 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
156 return WINED3DERR_INVALIDCALL
;
158 return IWineD3DDevice_SetCursorProperties(This
->WineD3DDevice
,XHotSpot
,YHotSpot
,(IWineD3DSurface
*)pSurface
->wineD3DSurface
);
161 static void WINAPI
IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface
, int XScreenSpace
, int YScreenSpace
, DWORD Flags
) {
162 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
163 TRACE("(%p) Relay\n", This
);
164 return IWineD3DDevice_SetCursorPosition(This
->WineD3DDevice
, XScreenSpace
, YScreenSpace
, Flags
);
167 static BOOL WINAPI
IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9 iface
, BOOL bShow
) {
168 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
169 TRACE("(%p) Relay\n", This
);
171 return IWineD3DDevice_ShowCursor(This
->WineD3DDevice
, bShow
);
174 static HRESULT WINAPI
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9 iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
) {
175 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
176 WINED3DPRESENT_PARAMETERS localParameters
;
177 TRACE("(%p) Relay pPresentationParameters(%p)\n", This
, pPresentationParameters
);
179 localParameters
.BackBufferWidth
= &pPresentationParameters
->BackBufferWidth
;
180 localParameters
.BackBufferHeight
= &pPresentationParameters
->BackBufferHeight
;
181 localParameters
.BackBufferFormat
= (WINED3DFORMAT
*)&pPresentationParameters
->BackBufferFormat
;
182 localParameters
.BackBufferCount
= &pPresentationParameters
->BackBufferCount
;
183 localParameters
.MultiSampleType
= (WINED3DMULTISAMPLE_TYPE
*) &pPresentationParameters
->MultiSampleType
;
184 localParameters
.MultiSampleQuality
= &pPresentationParameters
->MultiSampleQuality
;
185 localParameters
.SwapEffect
= (WINED3DSWAPEFFECT
*) &pPresentationParameters
->SwapEffect
;
186 localParameters
.hDeviceWindow
= &pPresentationParameters
->hDeviceWindow
;
187 localParameters
.Windowed
= &pPresentationParameters
->Windowed
;
188 localParameters
.EnableAutoDepthStencil
= &pPresentationParameters
->EnableAutoDepthStencil
;
189 localParameters
.AutoDepthStencilFormat
= (WINED3DFORMAT
*)&pPresentationParameters
->AutoDepthStencilFormat
;
190 localParameters
.Flags
= &pPresentationParameters
->Flags
;
191 localParameters
.FullScreen_RefreshRateInHz
= &pPresentationParameters
->FullScreen_RefreshRateInHz
;
192 localParameters
.PresentationInterval
= &pPresentationParameters
->PresentationInterval
;
193 return IWineD3DDevice_Reset(This
->WineD3DDevice
, &localParameters
);
196 static HRESULT WINAPI
IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface
, CONST RECT
* pSourceRect
,CONST RECT
* pDestRect
,HWND hDestWindowOverride
,CONST RGNDATA
*
198 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
199 TRACE("(%p) Relay\n", This
);
200 return IWineD3DDevice_Present(This
->WineD3DDevice
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
203 static HRESULT WINAPI
IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, UINT BackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
) {
204 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
205 IWineD3DSurface
*retSurface
= NULL
;
208 TRACE("(%p) Relay\n", This
);
210 rc
= IWineD3DDevice_GetBackBuffer(This
->WineD3DDevice
, iSwapChain
, BackBuffer
, (WINED3DBACKBUFFER_TYPE
) Type
, (IWineD3DSurface
**)&retSurface
);
211 if (rc
== D3D_OK
&& NULL
!= retSurface
&& NULL
!= ppBackBuffer
) {
212 IWineD3DSurface_GetParent(retSurface
, (IUnknown
**)ppBackBuffer
);
213 IWineD3DSurface_Release(retSurface
);
217 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
) {
218 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
219 TRACE("(%p) Relay\n", This
);
221 return IWineD3DDevice_GetRasterStatus(This
->WineD3DDevice
, iSwapChain
, (WINED3DRASTER_STATUS
*) pRasterStatus
);
224 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface
, BOOL bEnableDialogs
) {
225 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
226 TRACE("(%p) Relay\n", This
);
228 return IWineD3DDevice_SetDialogBoxMode(This
->WineD3DDevice
, bEnableDialogs
);
231 static void WINAPI
IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, DWORD Flags
, CONST D3DGAMMARAMP
* pRamp
) {
233 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
234 TRACE("(%p) Relay\n", This
);
236 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
237 return IWineD3DDevice_SetGammaRamp(This
->WineD3DDevice
, iSwapChain
, Flags
, (CONST WINED3DGAMMARAMP
*)pRamp
);
240 static void WINAPI
IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
) {
241 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
242 TRACE("(%p) Relay\n", This
);
244 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
245 return IWineD3DDevice_GetGammaRamp(This
->WineD3DDevice
, iSwapChain
, (WINED3DGAMMARAMP
*) pRamp
);
249 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
) {
251 IDirect3DSurface9Impl
*object
;
252 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
253 TRACE("(%p) Relay\n", This
);
254 if(MultisampleQuality
< 0) {
255 FIXME("MultisampleQuality out of range %d, substituting 0\n", MultisampleQuality
);
256 /*FIXME: Find out what windows does with a MultisampleQuality < 0 */
257 MultisampleQuality
=0;
260 if(MultisampleQuality
> 0){
261 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality
);
264 [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.
267 MultisampleQuality
=0;
269 /*FIXME: Check MAX bounds of MultisampleQuality*/
271 /* Allocate the storage for the device */
272 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DSurface9Impl
));
273 if (NULL
== object
) {
274 FIXME("Allocation of memory failed\n");
275 return D3DERR_OUTOFVIDEOMEMORY
;
278 object
->lpVtbl
= &Direct3DSurface9_Vtbl
;
281 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This
, Width
, Height
, Format
, *ppSurface
);
283 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
);
285 if (hrc
!= D3D_OK
|| NULL
== object
->wineD3DSurface
) {
288 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This
);
289 HeapFree(GetProcessHeap(), 0, object
);
291 IUnknown_AddRef(iface
);
292 object
->parentDevice
= iface
;
293 TRACE("(%p) : Created surface %p\n", This
, object
);
294 *ppSurface
= (LPDIRECT3DSURFACE9
) object
;
301 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
,
302 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
303 DWORD MultisampleQuality
, BOOL Lockable
,
304 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
306 /* Is this correct? */
307 return IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,Lockable
,FALSE
/*Discard*/, 0/*Level*/, ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_RENDERTARGET
,D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
312 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
,
313 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
314 DWORD MultisampleQuality
, BOOL Discard
,
315 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
317 return IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,TRUE
/* Lockable */,Discard
, 0/* Level */
318 ,ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_DEPTHSTENCIL
,
319 D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
323 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
) {
324 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
325 TRACE("(%p) Relay\n" , This
);
326 return IWineD3DDevice_UpdateSurface(This
->WineD3DDevice
, ((IDirect3DSurface9Impl
*)pSourceSurface
)->wineD3DSurface
, pSourceRect
, ((IDirect3DSurface9Impl
*)pDestinationSurface
)->wineD3DSurface
, pDestPoint
);
329 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9 iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
) {
330 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
331 TRACE("(%p) Relay\n" , This
);
332 return IWineD3DDevice_UpdateTexture(This
->WineD3DDevice
, ((IDirect3DBaseTexture9Impl
*)pSourceTexture
)->wineD3DBaseTexture
, ((IDirect3DBaseTexture9Impl
*)pDestinationTexture
)->wineD3DBaseTexture
);
335 /* This isn't in MSDN!
336 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pDestSurface) {
337 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
338 FIXME("(%p) : stub\n", This);
343 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pRenderTarget
, IDirect3DSurface9
* pDestSurface
) {
344 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
345 IDirect3DSurface9Impl
*renderTarget
= (IDirect3DSurface9Impl
*)pRenderTarget
;
346 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
347 TRACE("(%p) Relay\n" , This
);
348 return IWineD3DDevice_GetRenderTargetData(This
->WineD3DDevice
, renderTarget
->wineD3DSurface
, destSurface
->wineD3DSurface
);
351 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
) {
352 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
353 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
354 TRACE("(%p) Relay\n" , This
);
355 return IWineD3DDevice_GetFrontBufferData(This
->WineD3DDevice
, iSwapChain
, destSurface
->wineD3DSurface
);
358 static HRESULT WINAPI
IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestSurface
, CONST RECT
* pDestRect
, D3DTEXTUREFILTERTYPE Filter
) {
359 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
360 IDirect3DSurface9Impl
*src
= (IDirect3DSurface9Impl
*) pSourceSurface
;
361 IDirect3DSurface9Impl
*dst
= (IDirect3DSurface9Impl
*) pDestSurface
;
363 TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This
, src
, pSourceRect
, dst
, pDestRect
, Filter
);
364 if(Filter
!= D3DTEXF_NONE
) ERR("Texture filters not supported yet\n");
365 return IWineD3DSurface_Blt(dst
->wineD3DSurface
, (RECT
*) pDestRect
, src
->wineD3DSurface
, (RECT
*) pSourceRect
, 0, NULL
);
368 static HRESULT WINAPI
IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
) {
369 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
370 IDirect3DSurface9Impl
*surface
= (IDirect3DSurface9Impl
*)pSurface
;
371 TRACE("(%p) Relay\n" , This
);
373 /* Note: D3DRECT is compatible with WINED3DRECT */
374 return IWineD3DDevice_ColorFill(This
->WineD3DDevice
, surface
->wineD3DSurface
, (CONST WINED3DRECT
*)pRect
, color
);
377 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
379 if(Pool
== D3DPOOL_MANAGED
){
380 FIXME("Attempting to create a managed offscreen plain surface\n");
381 return D3DERR_INVALIDCALL
;
383 /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface.
385 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
387 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
388 Why, their always lockable?
389 should I change the usage to dynamic?
391 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
);
394 /* TODO: move to wineD3D */
395 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
* pRenderTarget
) {
396 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
397 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pRenderTarget
;
398 TRACE("(%p) Relay\n" , This
);
399 return IWineD3DDevice_SetRenderTarget(This
->WineD3DDevice
, RenderTargetIndex
, pSurface
? (IWineD3DSurface
*)pSurface
->wineD3DSurface
: NULL
);
402 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
**ppRenderTarget
) {
403 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
405 IWineD3DSurface
*pRenderTarget
;
407 TRACE("(%p) Relay\n" , This
);
409 if (ppRenderTarget
== NULL
) {
410 return D3DERR_INVALIDCALL
;
412 hr
=IWineD3DDevice_GetRenderTarget(This
->WineD3DDevice
,RenderTargetIndex
,&pRenderTarget
);
414 if (hr
== D3D_OK
&& pRenderTarget
!= NULL
) {
415 IWineD3DSurface_GetParent(pRenderTarget
,(IUnknown
**)ppRenderTarget
);
416 IWineD3DSurface_Release(pRenderTarget
);
418 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
419 *ppRenderTarget
= NULL
;
424 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pZStencilSurface
) {
425 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
426 IDirect3DSurface9Impl
*pSurface
;
428 TRACE("(%p) Relay\n" , This
);
430 pSurface
= (IDirect3DSurface9Impl
*)pZStencilSurface
;
431 return IWineD3DDevice_SetDepthStencilSurface(This
->WineD3DDevice
,NULL
==pSurface
?NULL
:(IWineD3DSurface
*)pSurface
->wineD3DSurface
);
434 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
**ppZStencilSurface
) {
435 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
437 IWineD3DSurface
*pZStencilSurface
;
439 TRACE("(%p) Relay\n" , This
);
440 if(ppZStencilSurface
== NULL
){
441 return D3DERR_INVALIDCALL
;
444 hr
=IWineD3DDevice_GetDepthStencilSurface(This
->WineD3DDevice
,&pZStencilSurface
);
445 if(hr
== D3D_OK
&& pZStencilSurface
!= NULL
){
446 IWineD3DSurface_GetParent(pZStencilSurface
,(IUnknown
**)ppZStencilSurface
);
447 IWineD3DSurface_Release(pZStencilSurface
);
449 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
450 *ppZStencilSurface
= NULL
;
455 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9 iface
) {
456 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
457 TRACE("(%p) Relay\n" , This
);
458 return IWineD3DDevice_BeginScene(This
->WineD3DDevice
);
461 static HRESULT WINAPI
IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9 iface
) {
462 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
463 TRACE("(%p) Relay\n" , This
);
464 return IWineD3DDevice_EndScene(This
->WineD3DDevice
);
468 static HRESULT WINAPI
IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9 iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
) {
469 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
470 TRACE("(%p) Relay\n" , This
);
472 /* Note: D3DRECT is compatible with WINED3DRECT */
473 return IWineD3DDevice_Clear(This
->WineD3DDevice
, Count
, (CONST WINED3DRECT
*) pRects
, Flags
, Color
, Z
, Stencil
);
476 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* lpMatrix
) {
477 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
478 TRACE("(%p) Relay\n" , This
);
480 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
481 return IWineD3DDevice_SetTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) lpMatrix
);
484 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
) {
485 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
486 TRACE("(%p) Relay\n" , This
);
488 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
489 return IWineD3DDevice_GetTransform(This
->WineD3DDevice
, State
, (WINED3DMATRIX
*) pMatrix
);
492 static HRESULT WINAPI
IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
) {
493 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
494 TRACE("(%p) Relay\n" , This
);
496 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
497 return IWineD3DDevice_MultiplyTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) pMatrix
);
500 static HRESULT WINAPI
IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface
, CONST D3DVIEWPORT9
* pViewport
) {
501 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
502 TRACE("(%p) Relay\n" , This
);
504 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
505 return IWineD3DDevice_SetViewport(This
->WineD3DDevice
, (const WINED3DVIEWPORT
*)pViewport
);
508 static HRESULT WINAPI
IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface
, D3DVIEWPORT9
* pViewport
) {
509 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
510 TRACE("(%p) Relay\n" , This
);
512 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
513 return IWineD3DDevice_GetViewport(This
->WineD3DDevice
, (WINED3DVIEWPORT
*)pViewport
);
516 static HRESULT WINAPI
IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface
, CONST D3DMATERIAL9
* pMaterial
) {
517 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
518 TRACE("(%p) Relay\n" , This
);
520 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
521 return IWineD3DDevice_SetMaterial(This
->WineD3DDevice
, (const WINED3DMATERIAL
*)pMaterial
);
524 static HRESULT WINAPI
IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface
, D3DMATERIAL9
* pMaterial
) {
525 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
526 TRACE("(%p) Relay\n" , This
);
528 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
529 return IWineD3DDevice_GetMaterial(This
->WineD3DDevice
, (WINED3DMATERIAL
*)pMaterial
);
532 static HRESULT WINAPI
IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
) {
533 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
534 TRACE("(%p) Relay\n" , This
);
536 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
537 return IWineD3DDevice_SetLight(This
->WineD3DDevice
, Index
, (const WINED3DLIGHT
*)pLight
);
540 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface
, DWORD Index
, D3DLIGHT9
* pLight
) {
541 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
542 TRACE("(%p) Relay\n" , This
);
544 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
545 return IWineD3DDevice_GetLight(This
->WineD3DDevice
, Index
, (WINED3DLIGHT
*)pLight
);
548 static HRESULT WINAPI
IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9 iface
, DWORD Index
, BOOL Enable
) {
549 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
550 TRACE("(%p) Relay\n" , This
);
551 return IWineD3DDevice_SetLightEnable(This
->WineD3DDevice
, Index
, Enable
);
554 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9 iface
, DWORD Index
, BOOL
* pEnable
) {
555 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
556 TRACE("(%p) Relay\n" , This
);
557 return IWineD3DDevice_GetLightEnable(This
->WineD3DDevice
, Index
, pEnable
);
560 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9 iface
, DWORD Index
, CONST
float* pPlane
) {
561 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
562 TRACE("(%p) Relay\n" , This
);
563 return IWineD3DDevice_SetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
566 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface
, DWORD Index
, float* pPlane
) {
567 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
568 TRACE("(%p) Relay\n" , This
);
569 return IWineD3DDevice_GetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
572 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD Value
) {
573 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
574 TRACE("(%p) Relay\n" , This
);
575 return IWineD3DDevice_SetRenderState(This
->WineD3DDevice
, State
, Value
);
578 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
) {
579 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
580 TRACE("(%p) Relay\n" , This
);
581 return IWineD3DDevice_GetRenderState(This
->WineD3DDevice
, State
, pValue
);
584 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface
, CONST D3DCLIPSTATUS9
* pClipStatus
) {
585 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
586 TRACE("(%p) Relay\n" , This
);
587 return IWineD3DDevice_SetClipStatus(This
->WineD3DDevice
, (const WINED3DCLIPSTATUS
*)pClipStatus
);
590 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface
, D3DCLIPSTATUS9
* pClipStatus
) {
591 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
592 TRACE("(%p) Relay\n" , This
);
593 return IWineD3DDevice_GetClipStatus(This
->WineD3DDevice
, (WINED3DCLIPSTATUS
*)pClipStatus
);
596 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, IDirect3DBaseTexture9
**ppTexture
) {
597 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
598 IWineD3DBaseTexture
*retTexture
= NULL
;
601 TRACE("(%p) Relay\n" , This
);
603 if(ppTexture
== NULL
){
604 return D3DERR_INVALIDCALL
;
607 rc
= IWineD3DDevice_GetTexture(This
->WineD3DDevice
, Stage
, (IWineD3DBaseTexture
**)&retTexture
);
608 if (rc
== D3D_OK
&& NULL
!= retTexture
) {
609 IWineD3DBaseTexture_GetParent(retTexture
, (IUnknown
**)ppTexture
);
610 IWineD3DBaseTexture_Release(retTexture
);
612 FIXME("Call to get texture (%d) failed (%p)\n", Stage
, retTexture
);
618 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, IDirect3DBaseTexture9
* pTexture
) {
619 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
620 TRACE("(%p) Relay %d %p\n" , This
, Stage
, pTexture
);
621 return IWineD3DDevice_SetTexture(This
->WineD3DDevice
, Stage
,
622 pTexture
==NULL
? NULL
:((IDirect3DBaseTexture9Impl
*)pTexture
)->wineD3DBaseTexture
);
625 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
) {
626 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
627 TRACE("(%p) Relay\n" , This
);
628 return IWineD3DDevice_GetTextureStageState(This
->WineD3DDevice
, Stage
, Type
, pValue
);
631 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
) {
632 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
633 TRACE("(%p) Relay\n" , This
);
634 return IWineD3DDevice_SetTextureStageState(This
->WineD3DDevice
, Stage
, Type
, Value
);
637 static HRESULT WINAPI
IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD
* pValue
) {
638 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
639 TRACE("(%p) Relay\n" , This
);
640 return IWineD3DDevice_GetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, pValue
);
643 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9 iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
) {
644 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
645 TRACE("(%p) Relay\n" , This
);
646 return IWineD3DDevice_SetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, Value
);
649 static HRESULT WINAPI
IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9 iface
, DWORD
* pNumPasses
) {
650 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
651 TRACE("(%p) Relay\n" , This
);
652 return IWineD3DDevice_ValidateDevice(This
->WineD3DDevice
, pNumPasses
);
655 static HRESULT WINAPI
IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9 iface
, UINT PaletteNumber
, CONST PALETTEENTRY
* pEntries
) {
656 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
657 TRACE("(%p) Relay\n" , This
);
658 return IWineD3DDevice_SetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
661 static HRESULT WINAPI
IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9 iface
, UINT PaletteNumber
, PALETTEENTRY
* pEntries
) {
662 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
663 TRACE("(%p) Relay\n" , This
);
664 return IWineD3DDevice_GetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
667 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface
, UINT PaletteNumber
) {
668 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
669 TRACE("(%p) Relay\n" , This
);
670 return IWineD3DDevice_SetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
673 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface
, UINT
* PaletteNumber
) {
674 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
675 TRACE("(%p) Relay\n" , This
);
676 return IWineD3DDevice_GetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
679 static HRESULT WINAPI
IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9 iface
, CONST RECT
* pRect
) {
680 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
681 TRACE("(%p) Relay\n" , This
);
682 return IWineD3DDevice_SetScissorRect(This
->WineD3DDevice
, pRect
);
685 static HRESULT WINAPI
IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9 iface
, RECT
* pRect
) {
686 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
687 TRACE("(%p) Relay\n" , This
);
688 return IWineD3DDevice_GetScissorRect(This
->WineD3DDevice
, pRect
);
691 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface
, BOOL bSoftware
) {
692 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
693 TRACE("(%p) Relay\n" , This
);
694 return IWineD3DDevice_SetSoftwareVertexProcessing(This
->WineD3DDevice
, bSoftware
);
697 static BOOL WINAPI
IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface
) {
698 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
699 TRACE("(%p) Relay\n" , This
);
700 return IWineD3DDevice_GetSoftwareVertexProcessing(This
->WineD3DDevice
);
703 static HRESULT WINAPI
IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9 iface
, float nSegments
) {
704 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
705 TRACE("(%p) Relay\n" , This
);
706 return IWineD3DDevice_SetNPatchMode(This
->WineD3DDevice
, nSegments
);
709 static float WINAPI
IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9 iface
) {
710 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
711 TRACE("(%p) Relay\n" , This
);
712 return IWineD3DDevice_GetNPatchMode(This
->WineD3DDevice
);
715 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT StartVertex
, UINT PrimitiveCount
) {
716 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
717 TRACE("(%p) Relay\n" , This
);
718 return IWineD3DDevice_DrawPrimitive(This
->WineD3DDevice
, PrimitiveType
, StartVertex
, PrimitiveCount
);
721 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
,
722 INT BaseVertexIndex
, UINT MinVertexIndex
, UINT NumVertices
, UINT startIndex
, UINT primCount
) {
723 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
724 TRACE("(%p) Relay\n" , This
);
726 /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
727 IWineD3DDevice_SetBaseVertexIndex(This
->WineD3DDevice
, BaseVertexIndex
);
728 return IWineD3DDevice_DrawIndexedPrimitive(This
->WineD3DDevice
, PrimitiveType
, MinVertexIndex
, NumVertices
, startIndex
, primCount
);
731 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT PrimitiveCount
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
732 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
733 TRACE("(%p) Relay\n" , This
);
734 return IWineD3DDevice_DrawPrimitiveUP(This
->WineD3DDevice
, PrimitiveType
, PrimitiveCount
, pVertexStreamZeroData
, VertexStreamZeroStride
);
737 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT MinVertexIndex
,
738 UINT NumVertexIndices
, UINT PrimitiveCount
, CONST
void* pIndexData
,
739 D3DFORMAT IndexDataFormat
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
740 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
741 TRACE("(%p) Relay\n" , This
);
742 return IWineD3DDevice_DrawIndexedPrimitiveUP(This
->WineD3DDevice
, PrimitiveType
, MinVertexIndex
, NumVertexIndices
, PrimitiveCount
,
743 pIndexData
, IndexDataFormat
, pVertexStreamZeroData
, VertexStreamZeroStride
);
746 static HRESULT WINAPI
IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9 iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
) {
747 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
748 TRACE("(%p) Relay\n" , This
);
749 return IWineD3DDevice_ProcessVertices(This
->WineD3DDevice
,SrcStartIndex
, DestIndex
, VertexCount
, ((IDirect3DVertexBuffer9Impl
*)pDestBuffer
)->wineD3DVertexBuffer
, ((IDirect3DVertexBuffer9Impl
*)pVertexDecl
)->wineD3DVertexBuffer
, Flags
);
752 HRESULT WINAPI
IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface
, DWORD FVF
) {
753 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
754 TRACE("(%p) Relay\n" , This
);
758 D3DVERTEXELEMENT9
* elements
= NULL
;
759 IDirect3DVertexDeclaration9
* pDecl
= NULL
;
761 hr
= vdecl_convert_fvf(FVF
, &elements
);
762 if (hr
!= S_OK
) goto exit
;
764 hr
= IDirect3DDevice9Impl_CreateVertexDeclaration(iface
, elements
, &pDecl
);
765 if (hr
!= S_OK
) goto exit
;
767 hr
= IDirect3DDevice9Impl_SetVertexDeclaration(iface
, pDecl
);
768 if (hr
!= S_OK
) goto exit
;
772 HeapFree(GetProcessHeap(), 0, elements
);
773 if (pDecl
) IUnknown_Release(pDecl
);
774 if (hr
!= S_OK
) return hr
;
777 return IWineD3DDevice_SetFVF(This
->WineD3DDevice
, FVF
);
780 HRESULT WINAPI
IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface
, DWORD
* pFVF
) {
781 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
782 TRACE("(%p) Relay\n" , This
);
783 return IWineD3DDevice_GetFVF(This
->WineD3DDevice
, pFVF
);
786 HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
* pStreamData
, UINT OffsetInBytes
, UINT Stride
) {
787 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
788 TRACE("(%p) Relay\n" , This
);
789 return IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, StreamNumber
,
790 pStreamData
==NULL
? NULL
:((IDirect3DVertexBuffer9Impl
*)pStreamData
)->wineD3DVertexBuffer
,
791 OffsetInBytes
, Stride
);
794 HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
**pStream
, UINT
* OffsetInBytes
, UINT
* pStride
) {
795 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
796 IWineD3DVertexBuffer
*retStream
= NULL
;
799 TRACE("(%p) Relay\n" , This
);
802 return D3DERR_INVALIDCALL
;
805 rc
= IWineD3DDevice_GetStreamSource(This
->WineD3DDevice
, StreamNumber
, (IWineD3DVertexBuffer
**)&retStream
, OffsetInBytes
, pStride
);
806 if (rc
== D3D_OK
&& NULL
!= retStream
) {
807 IWineD3DVertexBuffer_GetParent(retStream
, (IUnknown
**)pStream
);
808 IWineD3DVertexBuffer_Release(retStream
);
811 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes
, pStride
);
818 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, UINT Divider
) {
819 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
820 TRACE("(%p) Relay\n" , This
);
821 IWineD3DDevice_SetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
825 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, UINT
* Divider
) {
826 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
827 TRACE("(%p) Relay\n" , This
);
828 return IWineD3DDevice_GetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
831 static HRESULT WINAPI
IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface
, IDirect3DIndexBuffer9
* pIndexData
) {
832 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
833 TRACE("(%p) Relay\n", This
);
834 return IWineD3DDevice_SetIndices(This
->WineD3DDevice
,
835 pIndexData
==NULL
? NULL
:((IDirect3DIndexBuffer9Impl
*)pIndexData
)->wineD3DIndexBuffer
,
839 static HRESULT WINAPI
IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface
, IDirect3DIndexBuffer9
**ppIndexData
) {
840 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
841 IWineD3DIndexBuffer
*retIndexData
= NULL
;
845 TRACE("(%p) Relay\n", This
);
847 if(ppIndexData
== NULL
){
848 return D3DERR_INVALIDCALL
;
851 rc
= IWineD3DDevice_GetIndices(This
->WineD3DDevice
, &retIndexData
, &tmp
);
852 if (rc
== D3D_OK
&& NULL
!= retIndexData
) {
853 IWineD3DIndexBuffer_GetParent(retIndexData
, (IUnknown
**)ppIndexData
);
854 IWineD3DIndexBuffer_Release(retIndexData
);
856 if(rc
!= D3D_OK
) FIXME("Call to GetIndices failed\n");
862 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9 iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DRECTPATCH_INFO
* pRectPatchInfo
) {
863 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
864 TRACE("(%p) Relay\n", This
);
865 return IWineD3DDevice_DrawRectPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DRECTPATCH_INFO
*)pRectPatchInfo
);
867 /*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawTriPatch.asp*/
868 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9 iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DTRIPATCH_INFO
* pTriPatchInfo
) {
869 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
870 TRACE("(%p) Relay\n", This
);
871 return IWineD3DDevice_DrawTriPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DTRIPATCH_INFO
*)pTriPatchInfo
);
874 static HRESULT WINAPI
IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9 iface
, UINT Handle
) {
875 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
876 TRACE("(%p) Relay\n", This
);
877 return IWineD3DDevice_DeletePatch(This
->WineD3DDevice
, Handle
);
880 const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl
=
883 IDirect3DDevice9Impl_QueryInterface
,
884 IDirect3DDevice9Impl_AddRef
,
885 IDirect3DDevice9Impl_Release
,
886 /* IDirect3DDevice9 */
887 IDirect3DDevice9Impl_TestCooperativeLevel
,
888 IDirect3DDevice9Impl_GetAvailableTextureMem
,
889 IDirect3DDevice9Impl_EvictManagedResources
,
890 IDirect3DDevice9Impl_GetDirect3D
,
891 IDirect3DDevice9Impl_GetDeviceCaps
,
892 IDirect3DDevice9Impl_GetDisplayMode
,
893 IDirect3DDevice9Impl_GetCreationParameters
,
894 IDirect3DDevice9Impl_SetCursorProperties
,
895 IDirect3DDevice9Impl_SetCursorPosition
,
896 IDirect3DDevice9Impl_ShowCursor
,
897 IDirect3DDevice9Impl_CreateAdditionalSwapChain
,
898 IDirect3DDevice9Impl_GetSwapChain
,
899 IDirect3DDevice9Impl_GetNumberOfSwapChains
,
900 IDirect3DDevice9Impl_Reset
,
901 IDirect3DDevice9Impl_Present
,
902 IDirect3DDevice9Impl_GetBackBuffer
,
903 IDirect3DDevice9Impl_GetRasterStatus
,
904 IDirect3DDevice9Impl_SetDialogBoxMode
,
905 IDirect3DDevice9Impl_SetGammaRamp
,
906 IDirect3DDevice9Impl_GetGammaRamp
,
907 IDirect3DDevice9Impl_CreateTexture
,
908 IDirect3DDevice9Impl_CreateVolumeTexture
,
909 IDirect3DDevice9Impl_CreateCubeTexture
,
910 IDirect3DDevice9Impl_CreateVertexBuffer
,
911 IDirect3DDevice9Impl_CreateIndexBuffer
,
912 IDirect3DDevice9Impl_CreateRenderTarget
,
913 IDirect3DDevice9Impl_CreateDepthStencilSurface
,
914 IDirect3DDevice9Impl_UpdateSurface
,
915 IDirect3DDevice9Impl_UpdateTexture
,
916 IDirect3DDevice9Impl_GetRenderTargetData
,
917 IDirect3DDevice9Impl_GetFrontBufferData
,
918 IDirect3DDevice9Impl_StretchRect
,
919 IDirect3DDevice9Impl_ColorFill
,
920 IDirect3DDevice9Impl_CreateOffscreenPlainSurface
,
921 IDirect3DDevice9Impl_SetRenderTarget
,
922 IDirect3DDevice9Impl_GetRenderTarget
,
923 IDirect3DDevice9Impl_SetDepthStencilSurface
,
924 IDirect3DDevice9Impl_GetDepthStencilSurface
,
925 IDirect3DDevice9Impl_BeginScene
,
926 IDirect3DDevice9Impl_EndScene
,
927 IDirect3DDevice9Impl_Clear
,
928 IDirect3DDevice9Impl_SetTransform
,
929 IDirect3DDevice9Impl_GetTransform
,
930 IDirect3DDevice9Impl_MultiplyTransform
,
931 IDirect3DDevice9Impl_SetViewport
,
932 IDirect3DDevice9Impl_GetViewport
,
933 IDirect3DDevice9Impl_SetMaterial
,
934 IDirect3DDevice9Impl_GetMaterial
,
935 IDirect3DDevice9Impl_SetLight
,
936 IDirect3DDevice9Impl_GetLight
,
937 IDirect3DDevice9Impl_LightEnable
,
938 IDirect3DDevice9Impl_GetLightEnable
,
939 IDirect3DDevice9Impl_SetClipPlane
,
940 IDirect3DDevice9Impl_GetClipPlane
,
941 IDirect3DDevice9Impl_SetRenderState
,
942 IDirect3DDevice9Impl_GetRenderState
,
943 IDirect3DDevice9Impl_CreateStateBlock
,
944 IDirect3DDevice9Impl_BeginStateBlock
,
945 IDirect3DDevice9Impl_EndStateBlock
,
946 IDirect3DDevice9Impl_SetClipStatus
,
947 IDirect3DDevice9Impl_GetClipStatus
,
948 IDirect3DDevice9Impl_GetTexture
,
949 IDirect3DDevice9Impl_SetTexture
,
950 IDirect3DDevice9Impl_GetTextureStageState
,
951 IDirect3DDevice9Impl_SetTextureStageState
,
952 IDirect3DDevice9Impl_GetSamplerState
,
953 IDirect3DDevice9Impl_SetSamplerState
,
954 IDirect3DDevice9Impl_ValidateDevice
,
955 IDirect3DDevice9Impl_SetPaletteEntries
,
956 IDirect3DDevice9Impl_GetPaletteEntries
,
957 IDirect3DDevice9Impl_SetCurrentTexturePalette
,
958 IDirect3DDevice9Impl_GetCurrentTexturePalette
,
959 IDirect3DDevice9Impl_SetScissorRect
,
960 IDirect3DDevice9Impl_GetScissorRect
,
961 IDirect3DDevice9Impl_SetSoftwareVertexProcessing
,
962 IDirect3DDevice9Impl_GetSoftwareVertexProcessing
,
963 IDirect3DDevice9Impl_SetNPatchMode
,
964 IDirect3DDevice9Impl_GetNPatchMode
,
965 IDirect3DDevice9Impl_DrawPrimitive
,
966 IDirect3DDevice9Impl_DrawIndexedPrimitive
,
967 IDirect3DDevice9Impl_DrawPrimitiveUP
,
968 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP
,
969 IDirect3DDevice9Impl_ProcessVertices
,
970 IDirect3DDevice9Impl_CreateVertexDeclaration
,
971 IDirect3DDevice9Impl_SetVertexDeclaration
,
972 IDirect3DDevice9Impl_GetVertexDeclaration
,
973 IDirect3DDevice9Impl_SetFVF
,
974 IDirect3DDevice9Impl_GetFVF
,
975 IDirect3DDevice9Impl_CreateVertexShader
,
976 IDirect3DDevice9Impl_SetVertexShader
,
977 IDirect3DDevice9Impl_GetVertexShader
,
978 IDirect3DDevice9Impl_SetVertexShaderConstantF
,
979 IDirect3DDevice9Impl_GetVertexShaderConstantF
,
980 IDirect3DDevice9Impl_SetVertexShaderConstantI
,
981 IDirect3DDevice9Impl_GetVertexShaderConstantI
,
982 IDirect3DDevice9Impl_SetVertexShaderConstantB
,
983 IDirect3DDevice9Impl_GetVertexShaderConstantB
,
984 IDirect3DDevice9Impl_SetStreamSource
,
985 IDirect3DDevice9Impl_GetStreamSource
,
986 IDirect3DDevice9Impl_SetStreamSourceFreq
,
987 IDirect3DDevice9Impl_GetStreamSourceFreq
,
988 IDirect3DDevice9Impl_SetIndices
,
989 IDirect3DDevice9Impl_GetIndices
,
990 IDirect3DDevice9Impl_CreatePixelShader
,
991 IDirect3DDevice9Impl_SetPixelShader
,
992 IDirect3DDevice9Impl_GetPixelShader
,
993 IDirect3DDevice9Impl_SetPixelShaderConstantF
,
994 IDirect3DDevice9Impl_GetPixelShaderConstantF
,
995 IDirect3DDevice9Impl_SetPixelShaderConstantI
,
996 IDirect3DDevice9Impl_GetPixelShaderConstantI
,
997 IDirect3DDevice9Impl_SetPixelShaderConstantB
,
998 IDirect3DDevice9Impl_GetPixelShaderConstantB
,
999 IDirect3DDevice9Impl_DrawRectPatch
,
1000 IDirect3DDevice9Impl_DrawTriPatch
,
1001 IDirect3DDevice9Impl_DeletePatch
,
1002 IDirect3DDevice9Impl_CreateQuery
1006 /* Internal function called back during the CreateDevice to create a render target */
1007 HRESULT WINAPI
D3D9CB_CreateSurface(IUnknown
*device
, IUnknown
*pSuperior
, UINT Width
, UINT Height
,
1008 WINED3DFORMAT Format
, DWORD Usage
, WINED3DPOOL Pool
, UINT Level
,
1009 IWineD3DSurface
** ppSurface
, HANDLE
* pSharedHandle
) {
1011 HRESULT res
= D3D_OK
;
1012 IDirect3DSurface9Impl
*d3dSurface
= NULL
;
1013 BOOL Lockable
= TRUE
;
1015 if((Pool
== D3DPOOL_DEFAULT
&& Usage
!= D3DUSAGE_DYNAMIC
))
1019 res
= IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9
*)device
, Width
, Height
, (D3DFORMAT
)Format
,
1020 Lockable
, FALSE
/*Discard*/, Level
, (IDirect3DSurface9
**)&d3dSurface
, D3DRTYPE_SURFACE
,
1021 Usage
, (D3DPOOL
) Pool
, D3DMULTISAMPLE_NONE
, 0 /* MultisampleQuality */, pSharedHandle
);
1023 if (SUCCEEDED(res
)) {
1024 *ppSurface
= d3dSurface
->wineD3DSurface
;
1025 d3dSurface
->container
= pSuperior
;
1026 IUnknown_Release(d3dSurface
->parentDevice
);
1027 d3dSurface
->parentDevice
= NULL
;
1028 d3dSurface
->forwardReference
= pSuperior
;
1030 FIXME("(%p) IDirect3DDevice9_CreateSurface failed\n", device
);
1035 ULONG WINAPI
D3D9CB_DestroySurface(IWineD3DSurface
*pSurface
) {
1036 IDirect3DSurface9Impl
* surfaceParent
;
1037 TRACE("(%p) call back\n", pSurface
);
1039 IWineD3DSurface_GetParent(pSurface
, (IUnknown
**) &surfaceParent
);
1040 /* GetParent's AddRef was forwarded to an object in destruction.
1041 * Releasing it here again would cause an endless recursion. */
1042 surfaceParent
->forwardReference
= NULL
;
1043 return IDirect3DSurface9_Release((IDirect3DSurface9
*) surfaceParent
);