Inspired by Sara Ford’s Visual Studio Tips, I thought I would start writing a series of tips for Direct3D programmers. I doubt I will be able to be as prolific as Sara, with a new tip each and every single day.
So where do we start? Let’s start with the very basics for a native Direct3D programmer. You will need:
- A C++ development environment.
- A DirectX SDK.
- A version control system.
Once you have these in place, you’re ready to get started writing your own Direct3D programs.
A C++ Development Environment
Download a free copy of Visual C++ 2008 Express Edition.
The license allows you the freedom to develop and sell anything you create with it. The compiler is the same as the commercial compiler, including all the optimizations available. The current DirectX SDK supports the 2005 and 2008 editions Visual Studio only, so avoid earlier compilers and in particular avoid Visual C++ 6.
Visual Studio Add-Ins
The express editions of Visual Studio don’t support add-ins. Add-ins are tools that allow expansion of the capabilities of the integrated development environment provided by Visual Studio. There are add-ins that integrate with version control systems, improved intellisense and refactoring tools. These are only supported by the commercial editions of Visual Studio.
If you have a commercial edition of Visual Studio, I recommend that you download the free add-in Refactor! for C++.
This add-in provides simple refactoring support for C++ programmers, giving you the ability to easily rename identifiers, extract statements into their own method or function, move implementations between header and source files and more.
A DirectX Software Development Kit
The DirectX SDK provides the additional header and library files need to write Direct3D programs. Visual Studio ships with enough header and library files that you can write basic programs against the Win32 API. It lacks the headers and libraries for accessing the most recent features of DirectX. Microsoft improves the DirectX SDK continuously and releases a new version of it every few months, usually quarterly.
Download the most recent DirectX SDK from Microsoft’s DirectX Developer Center.
The SDK includes headers, libraries, and documentation. Also included are sample programs and models that demonstrate various visual effects implemented with Direct3D. Its recommended that you use the most recent version of the SDK for your applications.
After installing the SDK, you’ll want to check the search locations for headers and libraries to make sure the DirectX headers and files are found by the compiler. Check the settings for include files and library files and make sure that the appropriate directory for the DirectX SDK is listed first in the search order at the top of the list box. If the DirectX SDK directories are not listed first, it can lead to compilation errors.
After launching Visual Studio, select Tools / Options… from the menu and browse to the Projects and Solutions / VC++ Directories section in the tree view. On the right is a combobox showing the kind of file searched for in the paths shown in the list box:
A Version Control System
This is one that is overlooked by most beginners to Direct3D and game programming. You’ll want a version control system so that you can track your changes to your code. At the very least it serves as a backup for your source code. At best you’ll find that it lets you quickly back out of a large sequence of changes that just didn’t work out. Backing your way out of a dead end with a version control system is a very handy thing to have around.
There are a variety of version control systems out there and Wikipedia has a good list summarizing them. One that is very popular with commercial and open source programmers is Subversion. My first version control system was RCS when I was working on the X Server for a RISC workstation designed at Evans & Sutherland. Later, we switched to CVS, which was built on top of RCS. For a brief while, I used Visual SourceSafe, but it is generally considered to be an inferior version control system. (Even Microsoft doesn’t use that internally.)
I recommend that you download TortoiseSVN to use subversion.
TortoiseSVN is a subversion client that integrates nicely with the Windows shell. It adds an overlay to a file’s icon that shows its modified state with respect to the subversion repository. This makes it very handy and intuitive to see which files you have changed but not yet committed to version control.