Direct3D Device Interface

As with the Direct3D object, there is no distinct Direct3D device object. A Direct3D device is simply an interface for communicating with a DirectDrawSurface object used as a 3D-rendering target. The following example creates a Direct3D device interface to a DirectDrawSurface object:

LPDIRECTDRAWSURFACE lpDDSurface;

LPDIRECT3DDEVICE lpD3DDevice;

ddres = lpDD->CreateSurface(&ddsd, &lpDDSurface,

NULL);

if (FAILED(ddres))

.

.

.

ddres = lpDDSurface->QueryInterface(lpGuid,

&lpD3DDevice);

if (FAILED(ddres))

.

.

.

The same rules for reference counts and state lifetimes for objects apply to DirectDrawSurface objects and Direct3D devices. (For information about these rules, see Direct3D Driver Interface.) Additionally, multiple, distinct Direct3D device interfaces can be obtained for the same DirectDrawSurface object. It is possible, therefore, that a single DirectDrawSurface object could be the target for both a ramp-based device and an RGB-based device.