Introduction :
DirectX is
Microsofts proprietary technology for
multimedia and
game programming.
It is based on
ActiveX /
COM and provides an
abstraction of the underlying hardwares capabilities, allowing programs to be written that do not need to deal with the nitty-gritties of every brand of
hardware component.
Background :
In order to have a grasp about what DirectX is all about, we need to delve into the workings of
modern (and
ancient)
graphics hardware and a little history.
To display an image on your screen, your
graphics adapter maintains a block of
memory ( called the
frame buffer ) which is a matrix containing the intensity ( and color ) of the pixel at every
coordinate. All graphics involves rapid modification of this frame buffer.
In the
dark ages ( or
good old days ),
Old monks, in
dark cloisters, by the light of
flickering candles had to .. Er !
I mean, tough programmers had to do everything
the hard way, painstakingly manipulating the memory to produce all the
pretty colors.
When the
IBM PC first came out it had a
crummy graphics adapter called the
CGA, which was even worse than the hardware on the cheaper systems like the
Commodore-64 or the
BBC Micro, but that wouldn't keep the
good programmer down and heaps of great games were written. ( Remember
PC - Man,
Paratrooper ,
MoonBugs ? )
However PC games could never compare with
console games and it was a
jagged four coloured world for PC gamers.
Then IBM came up with the
VGA, and suddenly PC
game developers could enjoy an unbelievable ( at that time ) resolution of 640 x 480 with 16
simultaneous colors, or a 320 x 200 screen with a
mind-boggling 256 simultaneous colors! ( Pant! Pant! Drool!! )
Some of the best games ever (
Wolfenstein,
One Must Fall,
Doom,
Quake,
Stargun,
Tomb Raider etc. ) were developed for the VGA, but gamers craved for more
realistic graphics and
hardware vendors found differing and
incompatible ways of extending the VGA.
This left developers in a
quandary as they had to
take arms against a
sea of conflicting
graphic adapters ( and
write code for each of them) or by opposing, end their dreams of being
rich and famous.
Meanwhile, Windows was
spreading like the plague, but its graphics performance was
pathetic. Windows provided an
API called the
GDI which isolated developers from the
quirks of the underlying graphics hardware, but it was too slow to use for graphically intensive games ( hence we have
MineSweeper,
Solitaire,
Tetris etc. ).
The
problem was that while GDI was good for efficient
drawing of
GUI elements ( windows, buttons etc. ) and
WYSIWYG printing, it was not meant for the kind of graphics that games required. Moreover, Windows frowned upon
direct hardware access and there was no clean way to get access to the
hardware frame buffer unless you wrote a
DOS game, in which case you were limited to VGA resolutions.
There was a need for
a better way and Microsoft came up with DirectX ( actually they first came out with
WinG and
DCI, but that's a
story for another node! ).
DirectX components:
Initially, DirectX had only two major components
DirectDraw and
DirectSound. These provided
standard interfaces to access the graphics frame buffer and the sound hardware.
Then as
3D accelerators started getting popular, Direct3D was born ,
Multiplayer games begat DirectPlay and Microsoft threw in DirectMusic at some point.
So we now have:
- DirectDraw, providing access to the frame buffer, and any 2D graphics functions provided by the graphics adapter.
- DirectSound, providing access to sound hardware, hardware mixer and MIDI support.
- DirectMusic, providing dynamic, context sensitive music composition for games.
- DirectShow, providing interfaces for multimedia devices, video compression / decompression and streaming multimedia.
- Direct3D, which provides access to the 3D functionality of the hardware.
- DirectPlay, which simplifies creation of networked, multiplayer games.
The good :
The bad and ugly:
Anyone for MoonBugs 2?