Platform SDK: DirectX

Device Interfaces

[Visual Basic]

Note  The information in this topic applies only to applications written in C++. DirectX for Visual Basic does not use COM interfaces, nor does it support rendering with execute-buffers.

[C++]

Applications written in C++ use a device interface to manipulate a Direct3DDevice object's rendering states, lighting states, and to perform rendering operations. There are four COM interfaces for devices in Direct3D: IDirect3DDevice, IDirect3DDevice2, IDirect3DDevice3, and IDirect3DDevice7. Underlying these interfaces is one of two possible COM objects that expose either all of the first three interfaces or only the IDirect3DDevice7 interface. The device object—and thus the interfaces—that your application uses depends entirely on the method by which the device is created. For more information, see Creating a Direct3D Device. Devices that expose the legacy IDirect3DDevice, IDirect3DDevice2, and IDirect3DDevice3 interfaces represent features and rendering capabilities exposed in versions of DirectX earlier than DirectX 7.0. This documentation refers to these objects as old devices. Objects that expose the IDirect3DDevice7 interface, which this documentation refers to as new devices, represent the latest set of rendering features. Applications cannot migrate across this interface boundary by using the IUnknown::QueryInterface method because the old device object is unaware of the newest features and the new device object is designed for optimal performance, rather than backward compatibility. Direct3D requires that you choose which interface your application will use ahead of time.

This documentation largely assumes that you will use the latest interface. However, some knowledge of previous implementations might be useful. The IDirect3DDevice interface exposed in previous versions of DirectX provides methods used for programming with execute buffers. However, execute buffers were provided primarily for backward compatibility. Subsequent versions of DirectX abandoned execute buffers in favor of the much simpler DrawPrimitive model, greatly simplifying the code required to render a scene. The DrawPrimitive rendering approach is employed by all interfaces later than the IDirect3DDevice interface. Direct3D Immediate Mode in DirectX 7.0 introduces the IDirect3DDevice7 interface, which provides greater simplicity and hardware acceleration. The device object that exposes IDirect3DDevice7 is capable of performing hardware-accelerated transformation and lighting operations when running on certain hardware. For more information, see Immediate Mode Changes for DirectX 7.0. These interfaces share some common methods, especially the interfaces that perform DrawPrimitive rendering. For more information, see Rendering.

Prior to the introduction of the IDirect3DDevice2 interface in DirectX 5.0, Direct3D devices were actually interfaces to DirectDrawSurface objects. The IDirect3DDevice2 and IDirect3DDevice3 interfaces implement a device-object model in which a Direct3DDevice object is entirely separate from DirectDraw surfaces, and concepts such as lights, materials, and viewports are objects that can be associated with one or more devices to render a scene. On the other hand, the IDirect3DDevice7 interface simplifies the Direct3D object-model further by moving lighting, material, and viewport parameters from separate objects, into the device itself.

Note  There are no interface version numbers between IDirect3DDevice3 and IDirect3DDevice7.

Because devices are separated from DirectDraw surfaces and have independent lifetimes, Direct3D device objects can use various DirectDraw surfaces as render targets at different times if the application requires it. For more information, see IDirect3DDevice7::SetRenderTarget.