DirectDraw presents programmers with a single, unified object that encapsulates both the DirectDraw and Direct3D states. When you create a DirectDraw object and then use the IDirectDraw2::QueryInterface method to obtain an IDirect3D2 interface, the reference count of the DirectDraw object is 2.
The important implication of this is that the lifetime of the Direct3D driver state is the same as that of the DirectDraw object. Releasing the Direct3D interface does not destroy the Direct3D driver state. That state is not destroyed until all references to that object¾whether they are DirectDraw or Direct3D references¾have been released. Therefore, if you release a Direct3D interface while holding a reference to a DirectDraw driver interface, and then query the Direct3D interface again, the Direct3D state will be preserved.
In DirectX 2 and DirectX 3, a Direct3D device was aggregated off a DirectDraw surface¾that is, IDirect3DDevice and IDirectDrawSurface were two interfaces to the same object. A given Direct3D object supported multiple 3-D device types. The IDirect3D interface was used to find or enumerate the device types. The IDirect3D::EnumDevices and IDirect3D::FindDevice methods identified the various device types by unique interface IDs (IIDs), which were then used to retrieve a Direct3D device interface by calling the QueryInterface method on a DirectDraw surface. The lifetimes of the DirectDraw surface and the Direct3D device were identical, since the same object implemented them. This architecture did not allow the programmer to change the rendering target of the Direct3D device
In DirectX 5 there are two models of Direct3D device objects. In the new model, Direct3D devices are separate objects from DirectDraw surface objects. For backward compatibility with DirectX 3 applications, the earlier model, in which Direct3D devices and DirectDraw surfaces were aggregated, is also supported. You cannot use the new DirectX 5 features with the old model. If your application calls the QueryInterface method on a DirectDraw surface and retrieves an IDirect3DDevice, it is using the old device model. You cannot call the QueryInterface method on a device object created in this way to retrieve an IDirect3DDevice2 interface.
It is recommended that all applications written with the DirectX 5 Programmer's Reference use the new device object model.
In DirectX 5, the new device model has the Direct3D device as a separate object from a DirectDraw surface. The IDirect3D2 interface is used to find or enumerate the types of devices supported. However, IDirect3D2 identifies devices by unique IDs known as class IDs in COM (CLSID). These are used to uniquely identify one of the various classes that implement a given interface. Since there are multiple Direct3D devices with different capabilities (some software based, some hardware based), but each supports the same set of interfaces, a CLSID is used to identify which type of device object we want. The CLSID obtained from IDirect3D2::FindDevice or IDirect3D2::EnumDevices is then used in a call to the IDirect3D2::CreateDevice method to create a device. The device objects created in this fashion support both IDirect3DDevice and IDirect3DDevice2 interfaces. Unlike in DirectX 3, however, you cannot call QueryInterface on these objects to retrieve an IDirectDrawSurface interface. Instead, you must use the IDirect3DDevice2::GetRenderTarget method.
The IDirect3DTexture interface is not an interface to a distinct object type, but instead is another interface to a DirectDrawSurface object. The same rules for reference counts and state lifetimes that apply to IDirect3D2 interfaces to DirectDraw objects also apply to Direct3D textures.
The DirectDraw HEL supports the creation of texture, mipmap, and z-buffer surfaces. Furthermore, because of the tight integration of DirectDraw and Direct3D, a DirectDraw-enabled system always provides Direct3D support (in software emulation, at least). Therefore, the DirectDraw HEL exports the DDSCAPS_3DDEVICE flag to indicate that a surface can be used for 3-D rendering. DirectDraw drivers for hardware-accelerated 3-D display cards export this capability to indicate the presence of hardware-accelerated 3-D.