IDirect3D3::CreateDevice

The IDirect3D3::CreateDevice method creates a Direct3D device to be used with the DrawPrimitive methods.

HRESULT CreateDevice(
  REFCLSID rclsid,                    
  LPDIRECTDRAWSURFACE4 lpDDS,         
  LPDIRECT3DDEVICE3 *  lplpD3DDevice,
  LPUNKNOWN pUnkOuter   // See remarks
);
 

Parameters

rclsid
Class identifier for the new device. This value can be IID_IDirect3DHALDevice, IID_IDirect3DMMXDevice, or IID_IDirect3DRGBDevice. The IID_IDirect3DRampDevice, used for the ramp emulation device, is not supported by IDirect3D3. To use ramp emulation, you must use the legacy IDirect3D2 interface.
lpDDS
Address of the IDirectDrawSurface4 interface for the DirectDrawSurface object that will be the device's rendering target. The surface must have been created as a 3-D device by using the DDSCAPS_3DDEVICE capability.
lplpD3DDevice
Address that points to the new IDirect3DDevice3 interface when the method returns.
pUnkOuter
This parameter is provided for future compatibility with COM aggregation features. Currently, however, the IDirect3D3::CreateDevice method returns an error if this parameter is anything but NULL.

Return Values

If the method succeeds, the return value is D3D_OK.

If the method fails, the return value is an error. The method returns DDERR_INVALIDPARAMS if one of the arguments is invalid.

Remarks

This method was introduced with the IDirect3D2 interface. In previous versions of Direct3D, devices could be created only by calling the IDirectDrawSurface::QueryInterface method; devices created in this manner can only be used with execute buffers.

In the IDirect3D2 interface, the CreateDevice method accepts only three parameters, which are identical to the first three parameters for the IDirect3D3::CreateDevice method.

When you call IDirect3D3::CreateDevice, you create a device object that is separate from a DirectDraw surface object. This device uses a DirectDraw surface as a rendering target.

QuickInfo

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in d3d.h.
  Import Library: Use ddraw.lib.

See Also

IDirect3DDevice3, Creating a Direct3D Device, Direct3D Devices