Game Development Reference
In-Depth Information
Do I Have to Use DirectX?
If your platform of choice is the PC, you have to consider whether to use DirectX in
your game or try an alternative API for graphics, sound, and input.
Just to be perfectly clear, this section has nothing to do with how to draw a shaded
polygon under Direct3D. This section is going to enlighten you about why you would
choose something like OpenGL over Direct3D. Believe it or not, the choice isn
'
t clear
cut no matter what your religious beliefs.
All Roads Lead to Rome
It
s not possible for me to be more tired of the religious nature of the OpenGL/
DirectX debate. Any good programmer should understand what
'
s under the
hood of every API if you have to make a choice between them. Disregarding
DirectX simply because Microsoft made it is asinine.
'
Design Philosophy of DirectX
DirectX was designed to sit between the application and the hardware. If the hard-
ware was capable of performing an action itself, DirectX would call the driver and be
done with it. If the hardware wasn
t there, DirectX would emulate the call in soft-
ware. Clearly, that would be much slower.
One thing that was gained by this design philosophy was a single API for every hard-
ware combination that supported DirectX. Back in the old days (that would be the
early 1990s), programmers weren
'
'
t so lucky. A great example was all the work that
needed to be done for sound systems. Origin supported Adlib, Roland, and Sound-
Blaster with separate bits of code. Graphics were similar; the old EGA graphics stan-
dard was completely different than Hercules. Yes, there was a graphics system called
Hercules. It was a pain to support all this stuff!
Of course, DirectX isn ' t the simplest API to learn. COM is a weird thing to look at if
you aren
t used to it. It also seems weird to have 50 lines of code to initialize a 3D
rendering surface when OpenGL does it so much easier. Herein lies one basis for
religious argument: old-time C versus newfangled COM. Get over it long enough to
understand it and then make an informed choice.
DirectX exposes a lot more about what the hardware is capable of doing. Those
CAPS bits can tell you if your video card can support nothing, hardware transform
and lighting (T&L), or the latest shaders. Perhaps that means you ' ll load up denser
geometry or simply bring up a dialog box telling some loser that he needs a better
'
 
 
 
Search WWH ::




Custom Search