ReactOS  0.4.13-dev-259-g5ca9c9c
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 }
VOID AlignedFree(IN OUT LPVOID pObject)
Definition: d3d9_helpers.c:130
#define DDERR_OUTOFMEMORY
Definition: ddraw.h:111
struct IDirect3D9 * LPDIRECT3D9
Definition: d3d9.h:124
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
HRESULT AlignedAlloc(IN OUT LPVOID *ppObject, IN SIZE_T dwSize)
Definition: d3d9_helpers.c:95
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define DDERR_GENERIC
Definition: ddraw.h:72
#define S_OK
Definition: intsafe.h:59
#define D3D_OK
Definition: d3d.h:106
#define DPRINT1
Definition: precomp.h:8
static BOOL GetDisplayDeviceInfo(IN OUT LPDIRECT3D9_INT pDirect3D9)
Definition: d3d9_create.c:181
struct IDirect3D9Vtbl Direct3D9_Vtbl
Definition: d3d9_impl.c:1028
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

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 }
#define TRUE
Definition: types.h:120
BOOL GetDeviceData(LPD3D9_DEVICEDATA pDeviceData)
Definition: d3d9_caps.c:126
static HDC
Definition: imagelist.c:92
smooth NULL
Definition: ftsmooth.c:416
static HDC hDC
Definition: 3dtext.c:33
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define lstrcpynA
Definition: compat.h:408
#define DPRINT1
Definition: precomp.h:8
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
static BOOL IsGDIDriver(HDC hDC)
Definition: d3d9_create.c:48

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:395
BOOL WINAPI DeleteDC(_In_ HDC)
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by GetDirect3D9AdapterInfo(), and IDirect3DDevice9Base_Release().