Skip to content

Latest commit

 

History

History
168 lines (111 loc) · 8.57 KB

nf-d3d9-idirect3d9-createdevice.md

File metadata and controls

168 lines (111 loc) · 8.57 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:d3d9.IDirect3D9.CreateDevice
IDirect3D9::CreateDevice (d3d9.h)
The IDirect3D9::CreateDevice method (d3d9.h) creates a device to represent the display adapter.
CreateDevice
CreateDevice method [Direct3D 9]
CreateDevice method [Direct3D 9]
IDirect3D9 interface
IDirect3D9 interface [Direct3D 9]
CreateDevice method
IDirect3D9.CreateDevice
IDirect3D9::CreateDevice
d3d9helper/IDirect3D9::CreateDevice
direct3d9.idirect3d9__createdevice
f1a706e0-42fb-ed6e-c0c8-07fa6aef658a
direct3d9\idirect3d9__createdevice.htm
direct3d9
VS|directx_sdk|~\idirect3d9__createdevice.htm
08/10/2022
CreateDevice, CreateDevice method [Direct3D 9], CreateDevice method [Direct3D 9],IDirect3D9 interface, IDirect3D9 interface [Direct3D 9],CreateDevice method, IDirect3D9.CreateDevice, IDirect3D9::CreateDevice, d3d9helper/IDirect3D9::CreateDevice, direct3d9.idirect3d9__createdevice, f1a706e0-42fb-ed6e-c0c8-07fa6aef658a
d3d9.h
D3D9.h
Windows
D3D9.lib
Windows
19H1
IDirect3D9::CreateDevice
d3d9/IDirect3D9::CreateDevice
c++
APIRef
kbSyntax
COM
D3D9.lib
D3D9.dll
IDirect3D9.CreateDevice

IDirect3D9::CreateDevice

-description

Creates a device to represent the display adapter.

-parameters

-param Adapter [in]

Type: UINT

Ordinal number that denotes the display adapter. D3DADAPTER_DEFAULT is always the primary display adapter.

-param DeviceType [in]

Type: D3DDEVTYPE

Member of the D3DDEVTYPE enumerated type that denotes the desired device type. If the desired device type is not available, the method will fail.

-param hFocusWindow [in]

Type: HWND

The focus window alerts Direct3D when an application switches from foreground mode to background mode. See Remarks.

  • 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.

-param BehaviorFlags [in]

Type: DWORD

Combination of one or more options that control device creation. For more information, see D3DCREATE.

-param pPresentationParameters [in, out]

Type: D3DPRESENT_PARAMETERS*

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.

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, 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.

-param ppReturnedDeviceInterface [out, retval]

Type: IDirect3DDevice9**

Address of a pointer to the returned IDirect3DDevice9 interface, which represents the created device.

-returns

Type: HRESULT

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_DEVICELOST, 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. To begin rendering, the application needs only to create and set a depth buffer (assuming EnableAutoDepthStencil is FALSE in D3DPRESENT_PARAMETERS).

When you create a Direct3D device, you supply two different window parameters: a focus window (hFocusWindow) and a device window (the hDeviceWindow in D3DPRESENT_PARAMETERS). The purpose of each window is:

  • The focus window alerts Direct3D when an application switches from foreground mode to background mode (via Alt-Tab, a mouse click, or some other method). A single focus window is shared by each device created by an application.
  • The device window determines the location and size of the back buffer on screen. This is used by Direct3D when the back buffer contents are copied to the front buffer during Present.
This method should not be run during the handling of WM_CREATE. An application should never pass a window handle to Direct3D while handling WM_CREATE.
Any call to create, release, or reset the device must be done using 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 at least one of these vertex processing flags must be specified when calling this method.

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 Reset, IUnknown, and TestCooperativeLevel must be called from the same thread that used this method to create a device.

D3DFMT_UNKNOWN can be specified for the windowed mode back buffer format when calling CreateDevice, Reset, and CreateAdditionalSwapChain. This means the application does not have to query the current desktop format before calling CreateDevice for windowed mode. For full-screen mode, the back buffer format must be specified.

If you attempt to create a device on a 0x0 sized window, CreateDevice will fail.

-see-also

D3DDEVICE_CREATION_PARAMETERS

Direct3DCreate9

IDirect3D9

Multihead (Direct3D 9)

Reset