IDirect3D9Ex::CreateDeviceEx 

IDirect3D9Ex::CreateDeviceEx

Creates a device to represent the display adapter.

HRESULT CreateDeviceEx(
  UINT Adapter,
  D3DDEVTYPE DeviceType,
  HWND hFocusWindow,
  DWORD BehaviorFlags,
  D3DPRESENT_PARAMETERS* pPresentationParameters,
  D3DDISPLAYMODEEX* pFullscreenDisplayMode,
  IDirect3DDevice9Ex** ppReturnedDeviceInterface
);

Parameters

Adapter
Ordinal number that denotes the display adapter. D3DADAPTER_DEFAULT is always the primary display adapter.
DeviceType
Member of the D3DDEVTYPE enumerated type that denotes the desired device type. If the desired device type is not available, the method will fail. See D3DDEVTYPE.
hFocusWindow
The focus window alerts Direct3D when an application switches from foreground mode to background mode.
  • For full-screen mode, the window specified must be a top-level window.
  • For windowed mode, this parameter may be NULL only if the hDeviceWindow member of pPresentationParameters is set to a valid, non-NULL value.
BehaviorFlags
Combination of one or more options that control device creation. For more information, see D3DCREATE.
pPresentationParameters
[in, out] Pointer to a D3DPRESENT_PARAMETERS structure, describing the presentation parameters for the device to be created. If BehaviorFlags specifies D3DCREATE_ADAPTERGROUP_DEVICE, pPresentationParameters is an array. Regardless of the number of heads that exist, only one depth/stencil surface is automatically created. See D3DPRESENT_PARAMETERS.

For Windows 2000 and Windows XP, the full-screen device display refresh rate is set in the following order:

  1. User-specified nonzero ForcedRefreshRate registry key, if supported by the device.
  2. Application-specified nonzero refresh rate value in the presentation parameter.
  3. Refresh rate of the latest desktop mode, if supported by the device.
  4. 75 hertz if supported by the device.
  5. 60 hertz if supported by the device.
  6. Device default.

An unsupported refresh rate will default to the closest supported refresh rate below it. For example, if the application specifies 63 hertz, 60 hertz will be used. There are no supported refresh rates below 57 hertz.

pPresentationParameters is both an input and an output parameter. Calling this method may change several members including:

  • If BackBufferCount, BackBufferWidth, and BackBufferHeight are 0 before the method is called, they will be changed when the method returns.
  • If BackBufferFormat equals D3DFMT_UNKNOWN before the method is called, it will be changed when the method returns.

An additional clipping flag (D3DPRESENT_RESTRICT_TO_MONITOR) has been added to support clipping only in desktop composition mode in Windows Vista (see Desktop Window Manager). If you are not running in desktop composition mode, the flag gives the same behavior as D3DPRESENTFLAG_DEVICECLIP. If you are running in desktop composition mode (in Windows Vista only), this new behavior clips the contents to the monitor/device the adapter is targeting, show thumbnails for the content in the Flip3D view and taskbar thumbnails on other monitors.

pFullscreenDisplayMode
[in, out] The display mode for when the device is set to fullscreen. See D3DDISPLAYMODEEX.
ppReturnedDeviceInterface
[out, retval] Address of a pointer to the returned IDirect3DDevice9Ex Interface, which represents the created device.

Return Values

This method returns S_OK when rendering device along with swapchain buffers are created successfully. D3DERR_DEVICELOST is returned when any error other than invalid caller input is encountered.

See Also

IDirect3D9Ex Interface

Show: