C sharp:Drawing A Triangle

From GPWiki

Files:GUITutorial_warn.gif The Game Programming Wiki has moved! Files:GUITutorial_warn.gif

The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server.

However, the GPWiki forums are still active! Come say hello.

Files:GUITutorial_warn.gif This wiki page is under construction!

This page may be incomplete, missing information, or inaccurate!

DirectX device

Hello, I am DarkShadow. This is a tutorial on setting up a DirectX and drawing... A TRIANGLE! "A stupid triangle?", you may say. Well, you can't start out making Halo, so suck it up and start drawing this triangle. ;-)


This tutorial assumes some basic knowledge of C# and little bit of matrix math (not the movie). You need to have DirectX 9.0c (Summer 2005 update, I believe). The reason I use DirectX instead of OpenGL is because...well, I don't have a reason, maybe it's because I'm to lazy to learn it after all this DirectX stuff. You'll see. Just wait till you get to meshes!

Anyway, start up a new empty project in whatever compiler you use (if you use notepad and command prompt, I pity you, you poor fool). Empty, becuase we need to learn everything from scratch. This could work with a windows forms project, but don't try it. Add a new code file, name it whatever you want. I chose "Triangle"; simple and sweet.

Now, add these two using clauses at the top of your file.

using System;
using System.Windows.Forms;
 
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

Great! What the heck does that mean? The System namespace is what you need to run any program, but you should know that. System.Windows.Forms means you have the ability to create sweet graphics with a windows program! DirectX is to use DirectX