ReactOS 0.4.15-dev-8145-ga541a46
d3d9_create.h File Reference
#include <windows.h>
#include <d3d9types.h>
#include "d3d9_private.h"
Include dependency graph for d3d9_create.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HRESULT CreateD3D9 (OUT LPDIRECT3D9 *ppDirect3D9, UINT SDKVersion)
 
BOOL CreateD3D9DeviceData (IN LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter, IN LPD3D9_DEVICEDATA pDeviceData)
 
VOID DestroyD3D9DeviceData (IN LPD3D9_DEVICEDATA pDeviceData)
 

Function Documentation

◆ CreateD3D9()

HRESULT CreateD3D9 ( OUT LPDIRECT3D9 ppDirect3D9,
UINT  SDKVersion 
)

Definition at line 237 of file d3d9_create.c.

238{
239 LPDIRECT3D9_INT pDirect3D9;
240
241 if (ppDirect3D9 == 0)
242 return DDERR_INVALIDPARAMS;
243
244 if (AlignedAlloc((LPVOID *)&pDirect3D9, sizeof(DIRECT3D9_INT)) != S_OK)
245 return DDERR_OUTOFMEMORY;
246
247 if (pDirect3D9 == 0)
248 return DDERR_OUTOFMEMORY;
249
250 pDirect3D9->lpVtbl = &Direct3D9_Vtbl;
251 pDirect3D9->dwProcessId = GetCurrentThreadId();
252 pDirect3D9->lRefCnt = 1;
253
254 pDirect3D9->SDKVersion = SDKVersion;
255
256 pDirect3D9->lpInt = pDirect3D9;
257 pDirect3D9->unknown000007 = 1;
258
259 InitializeCriticalSection(&pDirect3D9->d3d9_cs);
260
261 if (FALSE == GetDisplayDeviceInfo(pDirect3D9))
262 {
263 DPRINT1("Could not create Direct3D9 object");
264 AlignedFree(pDirect3D9);
265 return DDERR_GENERIC;
266 }
267
268 *ppDirect3D9 = (LPDIRECT3D9)&pDirect3D9->lpVtbl;
269
270 return D3D_OK;
271}
#define DPRINT1
Definition: precomp.h:8
struct IDirect3D9 * LPDIRECT3D9
Definition: d3d9.h:124
struct IDirect3D9Vtbl Direct3D9_Vtbl
Definition: d3d9_impl.c:1028
static BOOL GetDisplayDeviceInfo(IN OUT LPDIRECT3D9_INT pDirect3D9)
Definition: d3d9_create.c:181
VOID AlignedFree(IN OUT LPVOID pObject)
Definition: d3d9_helpers.c:130
HRESULT AlignedAlloc(IN OUT LPVOID *ppObject, IN SIZE_T dwSize)
Definition: d3d9_helpers.c:95
#define D3D_OK
Definition: d3d.h:106
#define FALSE
Definition: types.h:117
#define S_OK
Definition: intsafe.h:52
#define DDERR_OUTOFMEMORY
Definition: ddraw.h:111
#define DDERR_GENERIC
Definition: ddraw.h:72
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by Direct3DCreate9().

◆ CreateD3D9DeviceData()

BOOL CreateD3D9DeviceData ( IN LPDIRECT3D9_DISPLAYADAPTER  pDisplayAdapter,
IN LPD3D9_DEVICEDATA  pDeviceData 
)

Definition at line 115 of file d3d9_create.c.

116{
117 HDC hDC;
118
119 /* Test DC creation for the display device */
120 if (NULL == (hDC = CreateDCA(NULL, pDisplayAdapter->szDeviceName, NULL, NULL)))
121 {
122 DPRINT1("Could not create dc for display adapter: %s", pDisplayAdapter->szDeviceName);
123 return FALSE;
124 }
125
126 pDeviceData->hDC = hDC;
127 pDeviceData->DisplayGuid = pDisplayAdapter->DisplayGuid;
128 pDeviceData->DeviceType = D3DDEVTYPE_HAL;
129 lstrcpynA(pDeviceData->szDeviceName, pDisplayAdapter->szDeviceName, CCHDEVICENAME);
130 pDeviceData->szDeviceName[CCHDEVICENAME-1] = '\0';
131
132 if (pDisplayAdapter->bInUseFlag)
133 {
134 pDeviceData->D3D9Callbacks.DeviceType = D3DDEVTYPE_HAL;
135 }
136 else if (IsGDIDriver(hDC))
137 {
138 pDeviceData->D3D9Callbacks.DeviceType = D3DDEVTYPE_REF;
139 }
140
141 if (FALSE == GetDeviceData(pDeviceData))
142 {
143 DPRINT1("Could not get device data for display adapter: %s", pDisplayAdapter->szDeviceName);
144 return FALSE;
145 }
146
147 return TRUE;
148}
static HDC hDC
Definition: 3dtext.c:33
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
@ D3DDEVTYPE_REF
Definition: d3d8types.h:577
BOOL GetDeviceData(LPD3D9_DEVICEDATA pDeviceData)
Definition: d3d9_caps.c:126
static BOOL IsGDIDriver(HDC hDC)
Definition: d3d9_create.c:48
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define lstrcpynA
Definition: compat.h:751
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)

Referenced by GetDirect3D9AdapterInfo(), and InitD3D9BaseDevice().

◆ DestroyD3D9DeviceData()

VOID DestroyD3D9DeviceData ( IN LPD3D9_DEVICEDATA  pDeviceData)

Definition at line 150 of file d3d9_create.c.

151{
152 DeleteDC(pDeviceData->hDC);
153 HeapFree(GetProcessHeap(), 0, pDeviceData->pUnknown6BC);
154}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by GetDirect3D9AdapterInfo(), and IDirect3DDevice9Base_Release().