2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS ReactX
4 * FILE: dll/directx/d3d9/d3d9_device.c
5 * PURPOSE: d3d9.dll internal device methods
6 * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
8 #include "d3d9_device.h"
9 #include "d3d9_helpers.h"
12 #include "d3d9_create.h"
13 #include "d3d9_mipmap.h"
15 #define LOCK_D3DDEVICE9() if (This->bLockDevice) EnterCriticalSection(&This->CriticalSection);
16 #define UNLOCK_D3DDEVICE9() if (This->bLockDevice) LeaveCriticalSection(&This->CriticalSection);
18 /* Convert a IDirect3DDevice9 pointer safely to the internal implementation struct */
19 LPDIRECT3DDEVICE9_INT
IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface
)
24 return (LPDIRECT3DDEVICE9_INT
)((ULONG_PTR
)iface
- FIELD_OFFSET(DIRECT3DDEVICE9_INT
, lpVtbl
));
27 static HRESULT
InvalidCall(LPDIRECT3DDEVICE9_INT This
, LPSTR ErrorMsg
)
29 DPRINT1("%s",ErrorMsg
);
31 return D3DERR_INVALIDCALL
;
34 /* IDirect3DDevice9: IUnknown implementation */
35 HRESULT WINAPI
IDirect3DDevice9Base_QueryInterface(LPDIRECT3DDEVICE9 iface
, REFIID riid
, void** ppvObject
)
37 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
39 if (IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_IDirect3DDevice9
))
41 IUnknown_AddRef(iface
);
42 *ppvObject
= &This
->lpVtbl
;
50 ULONG WINAPI
IDirect3DDevice9Base_AddRef(LPDIRECT3DDEVICE9 iface
)
52 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
53 ULONG ref
= InterlockedIncrement(&This
->lRefCnt
);
58 ULONG WINAPI
IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface
)
60 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
61 ULONG ref
= InterlockedDecrement(&This
->lRefCnt
);
67 EnterCriticalSection(&This
->CriticalSection
);
69 /* TODO: Free resources here */
70 for (iAdapter
= 0; iAdapter
< This
->NumAdaptersInDevice
; iAdapter
++)
72 DestroyD3D9DeviceData(&This
->DeviceData
[iAdapter
]);
74 This
->lpVtbl
->VirtualDestructor(iface
);
76 LeaveCriticalSection(&This
->CriticalSection
);
83 /* IDirect3DDevice9 public interface */
84 HRESULT WINAPI
IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface
)
92 * @name IDirect3DDevice9::GetAvailableTextureMem
95 * The function IDirect3DDevice9Base_GetAvailableTextureMem returns a pointer to the IDirect3D9 object
96 * that created this device.
98 * @param LPDIRECT3D iface
99 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
102 * The method returns an estimated the currently available texture memory in bytes rounded
103 * to the nearest MB. Applications should NOT use this as an exact number.
106 UINT WINAPI
IDirect3DDevice9Base_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface
)
108 UINT AvailableTextureMemory
= 0;
109 D3D9_GETAVAILDRIVERMEMORYDATA d3d9GetAvailDriverMemoryData
;
111 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
114 memset(&d3d9GetAvailDriverMemoryData
, 0, sizeof(d3d9GetAvailDriverMemoryData
));
115 d3d9GetAvailDriverMemoryData
.pUnknown6BC
= This
->DeviceData
[0].pUnknown6BC
;
116 d3d9GetAvailDriverMemoryData
.dwMemoryType
= D3D9_GETAVAILDRIVERMEMORY_TYPE_ALL
;
118 if (TRUE
== (*This
->DeviceData
[0].D3D9Callbacks
.DdGetAvailDriverMemory
)(&d3d9GetAvailDriverMemoryData
))
120 /* Round it up to the nearest MB */
121 AvailableTextureMemory
= (d3d9GetAvailDriverMemoryData
.dwFree
+ 0x80000) & 0xFFF00000;
125 return AvailableTextureMemory
;
128 HRESULT WINAPI
IDirect3DDevice9Base_EvictManagedResources(LPDIRECT3DDEVICE9 iface
)
136 * @name IDirect3DDevice9::GetDirect3D
139 * The function IDirect3DDevice9Base_GetDirect3D returns a pointer to the IDirect3D9 object
140 * that created this device.
142 * @param LPDIRECT3D iface
143 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
145 * @param IDirect3D9** ppD3D9
146 * Pointer to a IDirect3D9* to receive the IDirect3D9 object pointer.
149 * If the method successfully fills the ppD3D9 structure, the return value is D3D_OK.
150 * If ppD3D9 is a bad pointer, the return value will be D3DERR_INVALIDCALL.
153 HRESULT WINAPI
IDirect3DDevice9Base_GetDirect3D(LPDIRECT3DDEVICE9 iface
, IDirect3D9
** ppD3D9
)
155 IDirect3D9
* pDirect3D9
;
156 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
161 DPRINT1("Invalid ppD3D9 parameter specified");
163 return D3DERR_INVALIDCALL
;
166 pDirect3D9
= (IDirect3D9
*)&This
->pDirect3D9
->lpVtbl
;
167 IDirect3D9_AddRef(pDirect3D9
);
168 *ppD3D9
= pDirect3D9
;
175 * @name IDirect3DDevice9::GetDeviceCaps
178 * The function IDirect3DDevice9Base_GetDeviceCaps fills the pCaps argument with the
179 * capabilities of the device.
181 * @param LPDIRECT3D iface
182 * Pointer to the IDirect3D9 object returned from Direct3DCreate9()
184 * @param D3DCAPS9* pCaps
185 * Pointer to a D3DCAPS9 structure to be filled with the device's capabilities.
188 * If the method successfully fills the pCaps structure, the return value is D3D_OK.
189 * If pCaps is a bad pointer the return value will be D3DERR_INVALIDCALL.
192 HRESULT WINAPI
IDirect3DDevice9Base_GetDeviceCaps(LPDIRECT3DDEVICE9 iface
, D3DCAPS9
* pCaps
)
194 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
199 DPRINT1("Invalid pCaps parameter specified");
201 return D3DERR_INVALIDCALL
;
204 GetAdapterCaps(&This
->pDirect3D9
->DisplayAdapters
[0], This
->DeviceData
[0].DeviceType
, pCaps
);
211 * @name IDirect3DDevice9::GetDisplayMode
214 * The function IDirect3DDevice9Base_GetDisplayMode fills the pMode argument with the
215 * display mode for the specified swap chain.
217 * @param LPDIRECT3D iface
218 * Pointer to the IDirect3D9 object returned from Direct3DCreate9()
220 * @param UINT iSwapChain
221 * Swap chain index to get object for.
222 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
224 * @param D3DDISPLAYMODE* pMode
225 * Pointer to a D3DDISPLAYMODE structure to be filled with the current swap chain's display mode information.
228 * If the method successfully fills the pMode structure, the return value is D3D_OK.
229 * If iSwapChain is out of range or pMode is a bad pointer, the return value will be D3DERR_INVALIDCALL.
232 HRESULT WINAPI
IDirect3DDevice9Base_GetDisplayMode(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DDISPLAYMODE
* pMode
)
234 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
237 if (iSwapChain
>= IDirect3DDevice9_GetNumberOfSwapChains(iface
))
239 DPRINT1("Invalid iSwapChain parameter specified");
241 return D3DERR_INVALIDCALL
;
246 DPRINT1("Invalid pMode parameter specified");
248 return D3DERR_INVALIDCALL
;
251 pMode
->Width
= This
->DeviceData
[iSwapChain
].DriverCaps
.dwDisplayWidth
;
252 pMode
->Height
= This
->DeviceData
[iSwapChain
].DriverCaps
.dwDisplayHeight
;
253 pMode
->Format
= This
->DeviceData
[iSwapChain
].DriverCaps
.RawDisplayFormat
;
254 pMode
->RefreshRate
= This
->DeviceData
[iSwapChain
].DriverCaps
.dwRefreshRate
;
261 * @name IDirect3DDevice9::GetCreationParameters
264 * The function IDirect3DDevice9Base_GetCreationParameters fills the pParameters argument with the
265 * parameters the device was created with.
267 * @param LPDIRECT3D iface
268 * Pointer to the IDirect3D9 object returned from Direct3DCreate9()
270 * @param D3DDEVICE_CREATION_PARAMETERS* pParameters
271 * Pointer to a D3DDEVICE_CREATION_PARAMETERS structure to be filled with the creation parameter
272 * information for this device.
275 * If the method successfully fills the pParameters structure, the return value is D3D_OK.
276 * If pParameters is a bad pointer, the return value will be D3DERR_INVALIDCALL.
279 HRESULT WINAPI
IDirect3DDevice9Base_GetCreationParameters(LPDIRECT3DDEVICE9 iface
, D3DDEVICE_CREATION_PARAMETERS
* pParameters
)
281 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
284 if (NULL
== pParameters
)
286 DPRINT1("Invalid pParameters parameter specified");
288 return D3DERR_INVALIDCALL
;
291 pParameters
->AdapterOrdinal
= This
->AdapterIndexInGroup
[0];
292 pParameters
->DeviceType
= This
->DeviceType
;
293 pParameters
->hFocusWindow
= This
->hWnd
;
294 pParameters
->BehaviorFlags
= This
->BehaviourFlags
;
300 HRESULT WINAPI
IDirect3DDevice9Base_SetCursorProperties(LPDIRECT3DDEVICE9 iface
, UINT XHotSpot
, UINT YHotSpot
, IDirect3DSurface9
* pCursorBitmap
)
307 VOID WINAPI
IDirect3DDevice9Base_SetCursorPosition(LPDIRECT3DDEVICE9 iface
, int X
, int Y
, DWORD Flags
)
312 BOOL WINAPI
IDirect3DDevice9Base_ShowCursor(LPDIRECT3DDEVICE9 iface
, BOOL bShow
)
320 * @name IDirect3DDevice9::CreateAdditionalSwapChain
323 * The function IDirect3DDevice9Base_CreateAdditionalSwapChain creates a swap chain object,
324 * useful when rendering multiple views.
326 * @param LPDIRECT3D iface
327 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
329 * @param D3DPRESENT_PARAMETERS* pPresentationParameters
330 * Pointer to a D3DPRESENT_PARAMETERS structure describing the parameters for the swap chain
333 * @param IDirect3DSwapChain9** ppSwapChain
334 * Pointer to a IDirect3DSwapChain9* to receive the swap chain object pointer.
337 * If the method successfully fills the ppSwapChain structure, the return value is D3D_OK.
338 * If iSwapChain is out of range or ppSwapChain is a bad pointer, the return value
339 * will be D3DERR_INVALIDCALL. Also D3DERR_OUTOFVIDEOMEMORY can be returned if allocation
340 * of the new swap chain object failed.
343 HRESULT WINAPI
IDirect3DDevice9Base_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
, IDirect3DSwapChain9
** ppSwapChain
)
346 IDirect3DSwapChain9
* pSwapChain
;
347 Direct3DSwapChain9_INT
* pSwapChain_INT
;
348 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
351 if (NULL
== ppSwapChain
)
353 DPRINT1("Invalid ppSwapChain parameter specified");
355 return D3DERR_INVALIDCALL
;
359 iSwapChain
= IDirect3DDevice9_GetNumberOfSwapChains(iface
) + 1;
361 pSwapChain_INT
= CreateDirect3DSwapChain9(RT_EXTERNAL
, This
, iSwapChain
);
362 if (NULL
== pSwapChain_INT
)
364 DPRINT1("Out of memory");
366 return D3DERR_OUTOFVIDEOMEMORY
;
369 Direct3DSwapChain9_Init(pSwapChain_INT
, pPresentationParameters
);
371 This
->pSwapChains
[iSwapChain
] = pSwapChain_INT
;
372 pSwapChain
= (IDirect3DSwapChain9
*)&pSwapChain_INT
->lpVtbl
;
373 IDirect3DSwapChain9_AddRef(pSwapChain
);
374 *ppSwapChain
= pSwapChain
;
381 * @name IDirect3DDevice9::GetSwapChain
384 * The function IDirect3DDevice9Base_GetSwapChain returns a pointer to a swap chain object.
386 * @param LPDIRECT3D iface
387 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
389 * @param UINT iSwapChain
390 * Swap chain index to get object for.
391 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
393 * @param IDirect3DSwapChain9** ppSwapChain
394 * Pointer to a IDirect3DSwapChain9* to receive the swap chain object pointer.
397 * If the method successfully fills the ppSwapChain structure, the return value is D3D_OK.
398 * If iSwapChain is out of range or ppSwapChain is a bad pointer, the return value
399 * will be D3DERR_INVALIDCALL.
402 HRESULT WINAPI
IDirect3DDevice9Base_GetSwapChain(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, IDirect3DSwapChain9
** ppSwapChain
)
404 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
407 if (NULL
== ppSwapChain
)
409 DPRINT1("Invalid ppSwapChain parameter specified");
411 return D3DERR_INVALIDCALL
;
416 if (iSwapChain
>= IDirect3DDevice9_GetNumberOfSwapChains(iface
))
418 DPRINT1("Invalid iSwapChain parameter specified");
420 return D3DERR_INVALIDCALL
;
423 if (This
->pSwapChains
[iSwapChain
] != NULL
)
425 IDirect3DSwapChain9
* pSwapChain
= (IDirect3DSwapChain9
*)&This
->pSwapChains
[iSwapChain
]->lpVtbl
;
426 IDirect3DSwapChain9_AddRef(pSwapChain
);
427 *ppSwapChain
= pSwapChain
;
439 * @name IDirect3DDevice9::GetNumberOfSwapChains
442 * The function IDirect3DDevice9Base_GetNumberOfSwapChains returns the number of swap chains
443 * created by IDirect3D9::CreateDevice().
445 * @param LPDIRECT3D iface
446 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
449 * Returns the number of swap chains created by IDirect3D9::CreateDevice().
451 * NOTE: An application can create additional swap chains using the
452 * IDirect3DDevice9::CreateAdditionalSwapChain() method.
455 UINT WINAPI
IDirect3DDevice9Base_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface
)
459 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
462 NumSwapChains
= This
->NumAdaptersInDevice
;
465 return NumSwapChains
;
468 HRESULT WINAPI
IDirect3DDevice9Base_Reset(LPDIRECT3DDEVICE9 iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
)
476 * @name IDirect3DDevice9::Present
479 * The function IDirect3DDevice9Base_Present displays the content of the next
480 * back buffer in sequence for the device.
482 * @param LPDIRECT3D iface
483 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
485 * @param CONST RECT* pSourceRect
486 * A pointer to a RECT structure representing an area of the back buffer to display where
487 * NULL means the whole back buffer. This parameter MUST be NULL unless the back buffer
488 * was created with the D3DSWAPEFFECT_COPY flag.
490 * @param CONST RECT* pDestRect
491 * A pointer to a RECT structure representing an area of the back buffer where the content
492 * will be displayed where NULL means the whole back buffer starting at (0,0).
493 * This parameter MUST be NULL unless the back buffer was created with the D3DSWAPEFFECT_COPY flag.
495 * @param HWND hDestWindowOverride
496 * A destination window where NULL means the window specified in the hWndDeviceWindow of the
497 * D3DPRESENT_PARAMETERS structure.
499 * @param CONST RGNDATA* pDirtyRegion
500 * A pointer to a RGNDATA structure representing an area of the back buffer to display where
501 * NULL means the whole back buffer. This parameter MUST be NULL unless the back buffer
502 * was created with the D3DSWAPEFFECT_COPY flag. This is an optimization region only.
505 * If the method successfully displays the back buffer content, the return value is D3D_OK.
506 * If no swap chains are available, the return value will be D3DERR_INVALIDCALL.
508 HRESULT WINAPI
IDirect3DDevice9Base_Present(LPDIRECT3DDEVICE9 iface
, CONST RECT
* pSourceRect
, CONST RECT
* pDestRect
, HWND hDestWindowOverride
, CONST RGNDATA
* pDirtyRegion
)
512 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
515 iNumSwapChains
= IDirect3DDevice9Base_GetNumberOfSwapChains(iface
);
516 if (0 == iNumSwapChains
)
518 DPRINT1("Not enough swap chains, Present() fails");
520 return D3DERR_INVALIDCALL
;
523 for (i
= 0; i
< iNumSwapChains
; i
++)
526 IDirect3DSwapChain9
* pSwapChain
;
528 IDirect3DDevice9Base_GetSwapChain(iface
, i
, &pSwapChain
);
529 hResult
= IDirect3DSwapChain9_Present(pSwapChain
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
, 0);
543 * @name IDirect3DDevice9::GetBackBuffer
546 * The function IDirect3DDevice9Base_GetBackBuffer retrieves the back buffer
547 * for the specified swap chain.
549 * @param LPDIRECT3D iface
550 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
552 * @param UINT iSwapChain
553 * Swap chain index to get object for.
554 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
556 * @param UINT iBackBuffer
557 * Back buffer index to get object for.
558 * The maximum value for this is the the total number of back buffers - 1, as indexing starts at 0.
560 * @param IDirect3DSurface9** ppBackBuffer
561 * Pointer to a IDirect3DSurface9* to receive the back buffer object
564 * If the method successfully sets the ppBackBuffer pointer, the return value is D3D_OK.
565 * If iSwapChain or iBackBuffer is out of range, Type is invalid or ppBackBuffer is a bad pointer,
566 * the return value will be D3DERR_INVALIDCALL.
568 HRESULT WINAPI
IDirect3DDevice9Base_GetBackBuffer(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, UINT iBackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
)
571 IDirect3DSwapChain9
* pSwapChain
= NULL
;
572 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
575 IDirect3DDevice9Base_GetSwapChain(iface
, iSwapChain
, &pSwapChain
);
576 if (NULL
== pSwapChain
)
578 DPRINT1("Invalid iSwapChain parameter specified");
580 return D3DERR_INVALIDCALL
;
583 if (NULL
== ppBackBuffer
)
585 DPRINT1("Invalid ppBackBuffer parameter specified");
587 return D3DERR_INVALIDCALL
;
590 hResult
= IDirect3DSwapChain9_GetBackBuffer(pSwapChain
, iBackBuffer
, Type
, ppBackBuffer
);
597 * @name IDirect3DDevice9::GetRasterStatus
600 * The function IDirect3DDevice9Base_GetRasterStatus retrieves raster information
601 * of the monitor for the specified swap chain.
603 * @param LPDIRECT3D iface
604 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
606 * @param UINT iSwapChain
607 * Swap chain index to get object for.
608 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
610 * @param D3DRASTER_STATUS* pRasterStatus
611 * Pointer to a D3DRASTER_STATUS to receive the raster information
614 * If the method successfully fills the pRasterStatus structure, the return value is D3D_OK.
615 * If iSwapChain is out of range or pRasterStatus is a bad pointer, the return value
616 * will be D3DERR_INVALIDCALL.
618 HRESULT WINAPI
IDirect3DDevice9Base_GetRasterStatus(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
)
621 IDirect3DSwapChain9
* pSwapChain
= NULL
;
622 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
625 IDirect3DDevice9Base_GetSwapChain(iface
, iSwapChain
, &pSwapChain
);
626 if (NULL
== pSwapChain
)
628 DPRINT1("Invalid iSwapChain parameter specified");
630 return D3DERR_INVALIDCALL
;
633 if (NULL
== pRasterStatus
)
635 DPRINT1("Invalid pRasterStatus parameter specified");
637 return D3DERR_INVALIDCALL
;
640 hResult
= IDirect3DSwapChain9_GetRasterStatus(pSwapChain
, pRasterStatus
);
646 HRESULT WINAPI
IDirect3DDevice9Base_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface
, BOOL bEnableDialogs
)
654 * @name IDirect3DDevice9::SetGammaRamp
657 * The function IDirect3DDevice9Base_SetGammaRamp sets the gamma correction ramp values
658 * for the specified swap chain.
660 * @param LPDIRECT3D iface
661 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
663 * @param UINT iSwapChain
664 * Swap chain index to get object for.
665 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
668 * Can be on of the following:
669 * D3DSGR_CALIBRATE - Detects if a gamma calibrator is installed and if so modifies the values to correspond to
670 * the monitor and system settings before sending them to the display device.
671 * D3DSGR_NO_CALIBRATION - The gamma calibrations values are sent directly to the display device without
674 * @param CONST D3DGAMMARAMP* pRamp
675 * Pointer to a D3DGAMMARAMP representing the gamma correction ramp values to be set.
678 VOID WINAPI
IDirect3DDevice9Base_SetGammaRamp(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, DWORD Flags
, CONST D3DGAMMARAMP
* pRamp
)
680 IDirect3DSwapChain9
* pSwapChain
= NULL
;
681 Direct3DSwapChain9_INT
* pSwapChain_INT
;
682 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
685 IDirect3DDevice9Base_GetSwapChain(iface
, iSwapChain
, &pSwapChain
);
686 if (NULL
== pSwapChain
)
688 DPRINT1("Invalid iSwapChain parameter specified");
695 DPRINT1("Invalid pRamp parameter specified");
700 pSwapChain_INT
= IDirect3DSwapChain9ToImpl(pSwapChain
);
701 Direct3DSwapChain9_SetGammaRamp(pSwapChain_INT
, Flags
, pRamp
);
707 * @name IDirect3DDevice9::GetGammaRamp
710 * The function IDirect3DDevice9Base_GetGammaRamp retrieves the gamma correction ramp values
711 * for the specified swap chain.
713 * @param LPDIRECT3D iface
714 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
716 * @param UINT iSwapChain
717 * Swap chain index to get object for.
718 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
720 * @param D3DGAMMARAMP* pRamp
721 * Pointer to a D3DGAMMARAMP to receive the gamma correction ramp values.
724 VOID WINAPI
IDirect3DDevice9Base_GetGammaRamp(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
)
726 IDirect3DSwapChain9
* pSwapChain
= NULL
;
727 Direct3DSwapChain9_INT
* pSwapChain_INT
;
728 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
731 IDirect3DDevice9Base_GetSwapChain(iface
, iSwapChain
, &pSwapChain
);
732 if (NULL
== pSwapChain
)
734 DPRINT1("Invalid iSwapChain parameter specified");
741 DPRINT1("Invalid pRamp parameter specified");
746 pSwapChain_INT
= IDirect3DSwapChain9ToImpl(pSwapChain
);
747 Direct3DSwapChain9_GetGammaRamp(pSwapChain_INT
, pRamp
);
753 * @name IDirect3DDevice9::CreateTexture
756 * The function IDirect3DDevice9Base_CreateTexture creates a D3D9 texture.
758 * @param LPDIRECT3D iface
759 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
762 * Desired width of the texture
765 * Desired height of the texture
768 * Number of mip-maps. If Levels are zero, mip-maps down to size 1x1 will be generated.
771 * Valid combinations of the D3DUSAGE constants.
773 * @param D3DFORMAT Format
774 * One of the D3DFORMAT enum members for the surface format.
776 * @param D3DPOOL Pool
777 * One of the D3DPOOL enum members for where the texture should be placed.
779 * @param IDirect3DTexture9** ppTexture
780 * Return parameter for the created texture
782 * @param HANDLE* pSharedHandle
783 * Set to NULL, shared resources are not implemented yet
786 * Returns D3D_OK if everything went well.
789 HRESULT WINAPI
IDirect3DDevice9Base_CreateTexture(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
, UINT Levels
, DWORD Usage
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DTexture9
** ppTexture
, HANDLE
* pSharedHandle
)
792 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
796 return InvalidCall(This
, "Invalid 'this' parameter specified");
798 if (NULL
== ppTexture
)
799 return InvalidCall(This
, "Invalid ppTexture parameter specified");
803 if (D3DFMT_UNKNOWN
== Format
)
804 return InvalidCall(This
, "Invalid Format parameter specified, D3DFMT_UNKNOWN is not a valid Format");
806 if (NULL
!= pSharedHandle
)
809 return InvalidCall(This
, "Invalid pSharedHandle parameter specified, only NULL is supported at the moment");
812 hResult
= CreateD3D9MipMap(This
, Width
, Height
, Levels
, Usage
, Format
, Pool
, ppTexture
);
814 DPRINT1("Failed to create texture");
820 HRESULT WINAPI
IDirect3DDevice9Base_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
, UINT Depth
, UINT Levels
, DWORD Usage
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DVolumeTexture9
** ppVolumeTexture
, HANDLE
* pSharedHandle
)
827 HRESULT WINAPI
IDirect3DDevice9Base_CreateCubeTexture(LPDIRECT3DDEVICE9 iface
, UINT EdgeLength
, UINT Levels
, DWORD Usage
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DCubeTexture9
** ppCubeTexture
, HANDLE
* pSharedHandle
)
834 HRESULT WINAPI
IDirect3DDevice9Base_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface
, UINT Length
, DWORD Usage
, DWORD FVF
, D3DPOOL Pool
, IDirect3DVertexBuffer9
** ppVertexBuffer
, HANDLE
* pSharedHandle
)
841 HRESULT WINAPI
IDirect3DDevice9Base_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface
, UINT Length
, DWORD Usage
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DIndexBuffer9
** ppIndexBuffer
, HANDLE
* pSharedHandle
)
848 HRESULT WINAPI
IDirect3DDevice9Base_CreateRenderTarget(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
, BOOL Lockable
, IDirect3DSurface9
** ppSurface
, HANDLE
* pSharedHandle
)
855 HRESULT WINAPI
IDirect3DDevice9Base_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
, BOOL Discard
, IDirect3DSurface9
** ppSurface
, HANDLE
* pSharedHandle
)
862 HRESULT WINAPI
IDirect3DDevice9Base_UpdateSurface(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
)
869 HRESULT WINAPI
IDirect3DDevice9Base_UpdateTexture(LPDIRECT3DDEVICE9 iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
)
876 HRESULT WINAPI
IDirect3DDevice9Base_GetRenderTargetData(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pRenderTarget
, IDirect3DSurface9
* pDestSurface
)
884 * @name IDirect3DDevice9::GetFrontBufferData
887 * The function IDirect3DDevice9Base_GetFrontBufferData copies the content of
888 * the display device's front buffer in a system memory surface buffer.
890 * @param LPDIRECT3D iface
891 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
893 * @param UINT iSwapChain
894 * Swap chain index to get object for.
895 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
897 * @param IDirect3DSurface9* pDestSurface
898 * Pointer to a IDirect3DSurface9 to receive front buffer content
901 * If the method successfully fills the pDestSurface buffer, the return value is D3D_OK.
902 * If iSwapChain is out of range or pDestSurface is a bad pointer, the return value
903 * will be D3DERR_INVALIDCALL.
905 HRESULT WINAPI
IDirect3DDevice9Base_GetFrontBufferData(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
)
908 IDirect3DSwapChain9
* pSwapChain
= NULL
;
909 LPDIRECT3DDEVICE9_INT This
= IDirect3DDevice9ToImpl(iface
);
912 IDirect3DDevice9Base_GetSwapChain(iface
, iSwapChain
, &pSwapChain
);
913 if (NULL
== pSwapChain
)
915 DPRINT1("Invalid iSwapChain parameter specified");
917 return D3DERR_INVALIDCALL
;
920 if (NULL
== pDestSurface
)
922 DPRINT1("Invalid pDestSurface parameter specified");
924 return D3DERR_INVALIDCALL
;
927 hResult
= IDirect3DSwapChain9_GetFrontBufferData(pSwapChain
, pDestSurface
);
933 HRESULT WINAPI
IDirect3DDevice9Base_StretchRect(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestSurface
, CONST RECT
* pDestRect
, D3DTEXTUREFILTERTYPE Filter
)
940 HRESULT WINAPI
IDirect3DDevice9Base_ColorFill(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
)
947 HRESULT WINAPI
IDirect3DDevice9Base_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
** ppSurface
, HANDLE
* pSharedHandle
)
954 /* IDirect3DDevice9 private interface */
955 VOID WINAPI
IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface
)
960 VOID WINAPI
IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface
)