As with the object, there is no distinct Direct3D device object. A Direct3D device is simply an interface for communicating with a DirectDraw surface 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 (see Direct3D Driver Interface) apply to DirectDraw surfaces and Direct3D devices. Additionally, multiple, distinct Direct3D device interfaces can be obtained for the same DirectDraw surface. It is possible, therefore, that a single DirectDraw surface could be the target for both a ramp-based device and an RGB-based device.