i
i
i
i
i
i
i
i
336 13. Programming 3D Graphics in Real Time
13.3 Visualizing a Virtual Wo rld
Using Direct3D
Direct3D sets out to achieve the same result as OpenGL, but it does not have
such a long history and it is evolving at a much faster rate. For this reason,
we will not use it as our main framework for developing the visualization
examples. We will use the other components of DirectX, i.e., DirectInput
and DirectS how for all other software/hardware interfacing because it works
well and there are v ery few alternatives for Windows applications.
13.3.1 A Bit of History
DirectX [4] first appeared under the guise of the Games SDK for Windows 95
in late 1995, and it has been refined and updated many times. At first, it only
gave the ability to draw directly to the display hardware, and for the graphics
programmer that was a breath of fresh air. This is the DirectDraw compo-
nent of DirectX. It offer ed drawing speeds as fast as could be obtained if one
accessed the display adapter without using operating system mediation, say
by using assembler code. Di rectDraw was designed with 2D computer games
in mind, so it had excellent support for blits, bit-block memory transfers, in-
cluding transparent and “key color” blits. Many operations are performed
asynchronously with page flipping and color fills done in the display adapter’s
hardware.
All that the DirectDraw API provides is fast access to a drawing canvas,
the equivalent of the output frame buffer. To render virtual worlds or any-
thing else in 3D, one still has to render into the frame buffer, and this is
the function of Direct3D. The first few versions of Direct3D appeared in the
1990s. Back then, hardware support for 3D functions was still very limited
and so Direct3D had two modes of operation, called retained mode and im-
mediate mode. Retained mode [2] implemented most of the 3D functionality
in library code running in the host’s own processor, not on the GPU. Immedi-
ate mode was limited to a few simple functions and only managed to provide
some very basic lighting models, for example. Its functions matched the ca-
pabilities of the hardware rather than the desires of the application programs.
Now everything has changed. Retained mode has disappeared,
9
and imme-
diate mode has evolved to map onto the powerful features provided in hard-
9
Not quite, because it uses COM architecture and so is still in there, inside the Direct3D
system. It is just not documented.