Direct3D9 Tutorials in C++

My primary goal in doing these tutorials is to learn. By developing these tutorials I hope to learn my way around Direct3D much quicker than I would otherwise. Also I hope to be able to provide a valuable resource for others who want to learn.These examples may not always illustrate the best way to do things. I'm (mostly) human and fallible. I'm open to (constructive) criticism, if you have a better way of doing something, let me know.

These tutorials primarily cover Direct3D9, though other bits (notably DirectInput) maybe be covered to some degree. The DirectX SDK is required to compile them. The tutorials are written in C++, but I avoid using complex features of the language. If you can handle some simple objects then you know enough C++ to get by here.

For further help I highly recommend the very active community at

Version Note

These tutorials have been tested with the December 2006 version of the DirectX 9 SDK and compiled with Visual Studio 2005. Some changes may be required to the code if you are using a different version.

Frequently Asked Questions that often come my way. Just to be nice, I provide some answers too!
Tutorial FAQQuestions regarding my tutorials
Direct3D FAQQuestions regarding Direct3D in general

Getting It Together
All the things you need before you can start playing with the code.
What You NeedThe things you need to gather
Setting UpInstalling the toys you've gathered
Debug InfoSetting up and viewing DirectX's Debug Spew

The Basics
How to open a display and render simple things to it.
Windows PrimerHow to create a window and handle basic messages in C++/Win32
Initializing Direct3DInitializing Direct3D and creating a Direct3D Device. C++
3D PrimerA brief discussion of vertices and other concepts
PointsHow to cover your display with lots and lots of dots
LinesThe shortest path between 2 points is a straight line. Here's how to draw some.
TrianglesFans, Strips and Lists
Vertex BuffersNow that you can render the basic primitives, here's how to do it faster.
Model SpaceRendering an object defined in Model Space
World TransformTranslation, Rotation and Scaling
3D ObjectsSo far we've only rendered flat 2-dimensional objects. Now we'll render real 3D objects
Textured QuadAn example of applying a texture to a simple quad
Blending: Vertex AlphaAlpha blending with a per-vertex transparency.

Text and Fonts
Various methods of drawing text
Introduction to D3DXFontA look at the new D3DXFont interface that was introduced in the DX9 2003 Summer Update
3D TextUsing D3DX to create a mesh from text