Game Development Reference
In-Depth Information
processing or not. We need to know if it can in order to create the
IDirect3DDevice9 interface.
3. Initialize an instance of the D3DPRESENT_PARAMETERS structure.
This structure consists of a number of data members that allow us
to specify the characteristics of the IDirect3DDevice9 interface
that we are going to create.
4. Create the IDirect3DDevice9 object based on an initialized
D3DPRESENT_PARAMETERS structure. As said, the IDirect3D-
Device9 object is our C++ object that represents the physical
hardware device that we use for displaying 3D graphics.
Keep in mind that in this topic we use the primary display adapter for
drawing 3D graphics. If your system only has one graphics card, that is
the primary display adapter. If you have more than one graphics card,
then the card you are presently using is the primary display adapter
(e.g., the one displaying the Windows desktop, etc.).
1.4.1 Acquiring an IDirect3D9 Interface
Initialization of Direct3D begins by acquiring a pointer to an
IDirect3D9 interface. This is easily done using a special Direct3D
function, as the following lines of code show:
IDirect3D9* _d3d9;
_d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
The single parameter to Direct3DCreate9 should always be
D3D_SDK_VERSION, which guarantees that the application is built
against the correct header files. If this function fails, it returns a null
pointer.
The IDirect3D9 object is used for two things: device enumera-
tion and creating the IDirect3DDevice9 object. Device enumeration
refers to finding out the capabilities, display modes, formats, and other
information about each graphics device available on the system. For
instance, to create the IDirect3DDevice9 object that represents a
physical device, we need to create it using a configuration of display
modes and formats that the physical device supports. To find such a
working configuration, we must use the IDirect3D9 enumeration
methods.
However, because device enumeration can be quite an involved
task and we want to get up and running as quickly as possible with
Direct3D, we have elected not to perform any enumeration, except for
one check as shown in the next section. In order to safely skip
Search WWH ::




Custom Search