Click here to Skip to main content
11,920,394 members (50,740 online)
Click here to Skip to main content
Add your own
alternative version


46 bookmarked

Managed DirectX Tutorials: Part 1 - Setting Up DirectX

, 3 Feb 2006
Rate this:
Please Sign up or sign in to vote.
This is the first in a series of tutorials designed to show you how to create a basic terrain engine.


This is the first in a series of tutorials which will allow you to create your own game engine (from initialization, to a fully rotatable, height mapped 3D world!).

Although this particular edition is quite simple, it explains many of the key concepts to writing a DirectX application. Even if you have some experience with this API, I would advise you to at least skim read through this document before attempting other tutorials.

Please note that DirectX is not a good subject for beginners to programming or managed code - it makes full use of many features such as event handling etc. This tutorial will assume that you are familiar with the managed environment, C#, and Visual Studio.


The code from these tutorials is taken from my own game engine: MAGEngine.NET, at different stages in development.

Using the code

You may use all of the code I provide as how you see fit, except to create another tutorial. You can use it as a sturdy(ish Wink | ;) ) framework for your own applications, or print loads of copies off so that when I'm rich and famous you can sell them for $100 each Wink | ;)


To do this series of tutorials, you will need:

  • C# Compiler (preferably Visual C# 2005 Express)
  • Managed DirectX 9.0 October SDK

What Is DirectX?

DirectX is an API designed to give you (the programmer) a set of functions to access the GPU (Graphics Processing Unit) of a computer. Managed DirectX is split into multiple sections:

  • DirectX Graphics
  • DirectX Sound
  • DirectX Input

The First Steps

Before you can go ahead and make Doom IV, you need to slow down and take a few simple steps. First, download and install the DirectX SDK. Then install it to your hard drive. Now, in Visual C#, create a new Windows application called “DirectX Project”. To use the DirectX API, you need to tell the compiler to add certain references – just as in any other managed application. To do this, go to the Solution Explorer, and right click on the References folder. Click “Add Reference”. From there, choose the following references to add to your project:

  • Microsoft.DirectX
  • Microsoft.DirectX.Direct3D

Now, all you need to do is add using statements for these namespaces to the top of your code files. Now, when you make a new Windows application, Visual Studio generates more code than you need for a DirectX application. So, delete the “Designer” file for your window class, as we do not need this.

When you have done this, save your work and move onto Tutorial 2: Initializing Direct3D!


Please send all emails to I do have MSN Messenger, my email address for this is


  • 19/01/06: Submitted tutorials 1-3 to CodeProject.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

James Gupta
Web Developer
United States United States
I live in England, UK in a small town which only just got broadband...

In my spare time, I run a small website design, hosting and maintenance business at

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Aiteche8-Jun-10 23:14
memberAiteche8-Jun-10 23:14 
GeneralHi Pin
Taher Hassan25-Nov-07 13:02
memberTaher Hassan25-Nov-07 13:02 
QuestionWhere is directX? Pin
niko7815-Aug-06 14:34
memberniko7815-Aug-06 14:34 
AnswerRe: Where is directX? Pin
James Gupta20-Aug-06 5:57
memberJames Gupta20-Aug-06 5:57 
GeneralNice Series Pin
ThatsAlok4-Feb-06 3:06
memberThatsAlok4-Feb-06 3:06 
Competition is getting tougher and tougher ... I can't believe he is 14 only Smile | :) Next Bill Gates Smile | :)

"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

Alok Gupta
VC Forum Q&A :- I/ IV
GeneralRe: Nice Series Pin
James Gupta5-Feb-06 7:42
memberJames Gupta5-Feb-06 7:42 
GeneralRe: Nice Series Pin
[Marc]5-Feb-06 14:51
member[Marc]5-Feb-06 14:51 
GeneralA bit too short Pin
Marc Clifton3-Feb-06 17:32
protectorMarc Clifton3-Feb-06 17:32 
GeneralRe: A bit too short Pin
James Gupta5-Feb-06 7:40
memberJames Gupta5-Feb-06 7:40 
GeneralGood Articles, But... Pin
Rama Krishna Vavilala3-Feb-06 11:40
memberRama Krishna Vavilala3-Feb-06 11:40 
GeneralRe: Good Articles, But... Pin
James Gupta5-Feb-06 7:41
memberJames Gupta5-Feb-06 7:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151120.1 | Last Updated 3 Feb 2006
Article Copyright 2006 by James Gupta
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid