Original Post
The Windows Shortfall
If you’ll recall in 02.04 - Game Anatomy 101, I made the distinction between internal and external game elements. In this article, we’re going to take a look at a technology that does it all.
You might be wondering, “Aren’t there already ways to read the keyboard, play sounds and draw on the display right in Windows?” Sure there are, but they aren’t up to the task for games. For instance, GDI drawing routines are far too slow for the kind of frame rates we expect – heck, GDI was designed for business presentation graphics! Windows has no native support for all of the fancy things that sound cards are capable of these days, and you’re going to be fumbling to try and keyboard, mouse and joystick input in a proper and orderly fashion.
Enter: DirectX
Microsoft has long been aware of this, and has responded with a set of software components that interact with the hardware on a lower level, thereby drastically increasing performance. They’re called DirectX components, and address your sound, music, input, output and network needs. Here’s a list of the components (as of version 7.0):
Multi-Platform Parallel Development
There’s a willingness by many forum members to have the main material in this forum adopted to other graphics, input and sound tools, and for the most part I’m all for supporting as wide an array of multi-platform APIs as possible. Unfortunately, I doubt I’d have the time to perform the necessary translation myself. As is the case with my choice of language, you’re going to be limited to DirectX in the material I present (for the foreseeable future anyhow), but I am willing to entertain requests from others to take on a role in this tutorial series by representing the interests of other tools. More information on this ongoing issue will follow.
Arming Your Machine for DirectX
There are two components for DirectX: the user DLLs and the developer’s SDK. Both are available from Microsoft (http://www.microsoft.com/directx), but before you do, we’d better look at the various versions of DirectX that are available (and in use).
At the time of this writing, DirectX 7.0(a) and 8.0(a) are the main current versions. This forum uses version 7.0, which means that you need at least this version installed on your machine. Remember that you need both the runtime DLLs (for playing games) and the SDK for writing programs that use DirectX components. If you download and install a version later than 7.0, it includes everything you need. Let me rephrase that clearly:
Every version of DirectX is fully compatible with every previous version.
If you have DirectX 8.0, you can write games that use version 1, 3, 5, 6 or 7 (there’s no 2 or 4). Think about it – Microsoft couldn’t just scrap older versions or your games would stop working when you updated DirectX on your machine!
As I’ve mentioned, there are some DirectX-related files on my webpage, and you can pick and choose what to download instead of grabbing a 150MB file from Microsoft with a lot of useless contents. The one thing that I strongly encourage you to get (even if you have the DirectX 8.0 SDK) is the documentation for DirectX 7.0. Trust me, you’ll need this. The version 8.0 documentation isn’t going to help you. And if you proceed without this documentation at your fingertips, you’re as good as dead .
One question remains – if DirectX 8.0 is available right now, why are we using version 7.0 for the tutorials? Well, this is still under debate by many here, but I basically have two reasons:
- DirectDraw
- DirectInput
- DirectSound
- DirectMusic
- DirectPlay
- Direct3D
- OpenGL (Open graphics library – very popular as well)
- GlIDE (3DFX’s native API for Voodoo-based video cards)
- Allegro (a multi-platform graphics library)
- SDL (another multi-platform graphics library – thanks to pazu for the heads-up)
- MIDAS (a third-party sound support API)
- DirectX 7.0 is still very popular – it’s bound to be the most compatible for writing a game with.
- The way things are done in DirectDraw has been massively overhauled in version 8.0 (so much so, DirectDraw doesn’t even exist in 8.0!), and although it’s not the newest anymore, it’s still the most ‘compatible’ when learning to use graphics APIs.
- DirectX 7.0 (or higher) runtime DLLs – you can check this by going to your Start Menu/Run… and typing DXDIAG. Somewhere on the first tab of this utility is the current DirectX version number on your machine.
- DirectX 7.0 SDK (or higher) – you need the C++ libraries at the very least. Also included in the install package is a whack of samples that you may or may not be interested in (but I do highly recommend that you get them – many of the samples are great to learn from)
- DirectX 7.0 Online Documentation – this comes with the complete DirectX 7.0 SDK, but not with version 8.0. I’ve already told you that this is important, and that it’s available on my webpage.