Welcome to the first entry of the Managed DirectX 9 Tutorial. This tutorial is aimed at people who haven't done any 3D programming so far and would like to see some results in the shortest possible time. To this end, C# is an ideal programming language. C# is a relatively easy language, so anyone who has some basic programming experience should be able to start right away. Even more, this tutorial is written in such a way that anyone who has any programming experience should be able to understand and complete it.
Opening your project window
The required software to start writing your own DirectX 9 code :
A C# programming environment. Popular is Visual Studio .NET, but you can also download the free evaluation version of Borland C# Builder. Recently, Microsoft has released a free version of Visual Studio, Visual Studio Express, which you can download here: (link)
The .NET framework. (free) (link)
And of course the DirectX9 SDK. (free) (link)
With all this software installed, you can start a new C# Application. To do this in Visual Studio, click the File menu and select New. As project type, we of course need Visual C#. Now on the right, you can select Windows Application. Fill in the name, and hit the OK button!
Now you should see a small empty form. To switch to the code, find Program.cs at the right of your screen. Right click on it and select View code. Next, you should add a reference to Microsoft.DirectX and to Microsoft.DirectX.Direct3D. This is how you do it: in Visual Studio, go to the Project menu, and select ‘Add reference…’. In the list that comes up, pick Microsoft.DirectX and Microsoft.DirectX.Direct3D. Be sure NOT to select DirectX version 2.0. Also add the following lines to you using-block, so your program can use the referenced libraries:
Compiling this will already give you an empty form. Now we want to change the size and the title of it. To do this, simply find the InitializeComponent() method and change the size to (500,500) and the title (= this.Text) to "DirectX Tutorial" or whatever you like.
Next we are going to change the Main() method a bit:
static void Main()
using (WinForm our_directx_form = new WinForm())
You are now ready to start programming with DirectX! Compiling this code should give you a small form.
Click here to go to the forum on this chapter!
Or click on one of the topics on this chapter to go there:
visual studio 2010 hangs
Hi,as soon as i put the references in c# program.c...Form size without border
When I change the form size to 640x480 the wh...Get Started
I have Windows 7, DirectX SDK, and VS 2010.
How...Visual C# Epress 2010 and references
i have been wanting so badly to follow you...Problem with Opening the WinForm
im trying to Open a Form in a DirectX9 Gam...WinForm not found
using System.Collections.Ge...download links outdated
The links on this page have expired ...System.BadImageFormatException
I'm working on a 64bit laptop and just installed ...Add Reference to Microsoft.Direct3D
Hi, I'm new to Game development, but have been us...Microsoft.Samples.DirectX.UtilityToolkit
(Hey the topic is exactly 40 chars! And sorry if t...Opening your project window
K been stuck on this for hours now lol.
I cant ma...Build Error
When im done with the code and debug i get a build...not win 32 application
I have visoual studio 2005 prof edition, ...Why am i gettin CMD window...
Why am i gettin CMD window... i dont want the cons...Run .exe file
Hi, I'm a C# n00b,
I have followed this tutorial...WinForm or Form?
I'm not sure if this is right, but using Visual S...starting
yes when i create the windows application in the c...Linking Errors
Hi, I'm using VSC++ 2005. The program compiles, ...Linking Errors
Hi, I'm using VSC++ 2005. The program compiles, ...initialize component method
where is the initialize component() method? The on...Problem...
When I put in all the code that you said, I got th...where should I start write code?
Hello, I am new in DirectX programmin.
I am using...Error..
when i type :
After each chapter I will list the whole code so far, so this is what you should have by now :
public class WinForm : System.Windows.Forms.Form
private Device device;
private System.ComponentModel.Container components = null;
protected override void Dispose (bool disposing)
if (components != null)
private void InitializeComponent()
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(500,500);
this.Text = "DirectX Tutorial";
static void Main()
using (WinForm our_dx_form = new WinForm())
- Website design & XNA + DirectX code : Riemer Grootjans -
©2003 - 2011 Riemer Grootjans