DirectX SDK |
This topic pertains only to applications written in C++. For an introduction to programming for DirectX in Visual Basic, see Visual Basic Programming Topics.
Most of the DirectX API is composed of objects and interfaces based on COM. COM is the foundation of an object-based system that focuses on reuse of interfaces. It is also an interface specification from which any number of interfaces can be built.
A DirectX application is built from instances of COM objects. You can consider an object to be a black box that represents hardware or data that you access through interfaces. Commands are sent to the object through methods of the COM interface. For example, the IDirectDraw7::GetDisplayMode method of the IDirectDraw7 interface is called to get the current display mode of the display adapter from the DirectDraw object.
Objects can bind to other objects at run time, and they can use the implementation of interfaces provided by the other object. If you know that an object is a COM object and you know which interfaces that object supports, your application (or another object) can determine which services the first object can perform. One of the methods that all COM objects inherit, the QueryInterface method, lets you determine which interfaces an object supports and creates pointers to these interfaces. For more information, see the IUnknown Interface.
More information about COM programming for DirectX is found in the following topics: