Microsoft DirectX 8.1 (C++)

IDirect3D8::CreateDevice

Creates a device to represent the display adapter.

HRESULT CreateDevice(
  UINT Adapter,
  D3DDEVTYPE DeviceType,
  HWND  hFocusWindow,
  DWORD BehaviorFlags,
  D3DPRESENT_PARAMETERS* pPresentationParameters,
  IDirect3DDevice8** ppReturnedDeviceInterface
);

Parameters

Adapter
[in] Ordinal number that denotes the display adapter. D3DADAPTER_DEFAULT is always the primary display adapter.
DeviceType
[in] Member of the D3DDEVTYPE enumerated type. Denotes the desired device type. If the desired device type is not available, the method will fail.
hFocusWindow
[in] Window handle to which focus belongs for this Microsoft® Direct3D® device. The window specified must be a top-level window for full-screen.
BehaviorFlags
[in] A combination of one or more flags that control global behaviors of the Direct3D device.
D3DCREATE_FPU_PRESERVE
Indicates that the application needs either double precision floating-point unit (FPU) or FPU exceptions enabled. Direct3D sets the FPU state each time it is called. Setting the flag will reduce Direct3D performance.
D3DCREATE_HARDWARE_VERTEXPROCESSING
Specifies hardware vertex processing. See Remarks.
D3DCREATE_MIXED_VERTEXPROCESSING
Specifies mixed (both software and hardware) vertex processing. See Remarks.
D3DCREATE_MULTITHREADED
Indicates that the application requests Direct3D to be multithread safe. This makes Direct3D take its global critical section more frequently, which can degrade performance.
D3DCREATE_PUREDEVICE
Specifies that Direct3D does not support Get* calls for anything that can be stored in state blocks. It also tells Direct3D not to provide any emulation services for vertex processing. This means that if the device does not support vertex processing, then the application can use only post-transformed vertices.
D3DCREATE_SOFTWARE_VERTEXPROCESSING
Specifies software vertex processing. See Remarks.
D3DCREATE_DISABLE_DRIVER_MANAGEMENT
Specifies that Direct3D should manage resources instead of the driver.
pPresentationParameters
[in, out] Pointer to a D3DPRESENT_PARAMETERS structure, describing the presentation parameters for the device to be created. Calling CreateDevice can change the value of the BackBufferCount member of D3DPRESENT_PARAMETERS; the back buffer count is changed to reflect a corrected number of back buffers.
ppReturnedDeviceInterface
[out, retval] Address of a pointer to the returned IDirect3DDevice8 interface, representing the created device.

Return Values

If the method succeeds, the return value is D3D_OK.

If the method fails, the return value can be one of the following values.

D3DERR_INVALIDCALL
D3DERR_NOTAVAILABLE
D3DERR_OUTOFVIDEOMEMORY

Remarks

This method returns a fully working device interface, set to the required display mode (or windowed), and allocated with the appropriate back buffers. The application only needs to create and set a depth buffer, if desired, to begin rendering.

This method should not be executed during the handling of WM_CREATE. Therefore, the application should never pass a window handle to Direct3D while handling WM_CREATE. Microsoft® DirectX® 8.1 applications can expect messages to be sent to them during this call—that is, before this call is returned. Applications should take precautions not to call into Direct3D at this time. In addition, note that a call to create, release, or reset the device can only happen on the same thread as the window procedure of the focus window.

Note that D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DCREATE_MIXED_VERTEXPROCESSING, and D3DCREATE_SOFTWARE_VERTEXPROCESSING are mutually exclusive flags, and that at least one of these vertex processing flags must be specified when calling CreateDevice.

Back buffers created as part of the device are only lockable if D3DPRESENTFLAG_LOCKABLE_BACKBUFFER is specified in the presentation parameters. (Multisampled back buffers and depth surfaces are never lockable.)

The methods IDirect3DDevice8::Reset, Release, and IDirect3DDevice8::TestCooperativeLevel must be called from the same thread that used CreateDevice to create a device.

Requirements

  Header: Declared in D3d8.h.
  Import Library: Use D3d8.lib.

See Also

Direct3DCreate8, IDirect3DDevice8::Reset, D3DDEVICE_CREATION_PARAMETERS