Sunday, April 27, 2008

Fun with DirectX SDK

Whew! What a stressful week! I've been looking forward for this weekend to cave in my room and relax. Instead of talking about my SCTP work, I decided to spend my weekend to play around with DirectX SDK.

There was a point that I considered myself a hard-core gamer. I remember the days back in college where I save every little bit of my allowance just to get that state-of-the-art Video Card. You'll often find me browsing the net looking at the colorful video card performance comparison graphs on guru3d making sure I'd get the best card for my hard-earned cash. Then after 6 months I got a Radeon 9600 which was a midrange card at that time. It was money well spent and even after five years I still use it.

After wasting hours shooting pixelated enemies with my trusty video card, I got interested on DirectX. If you're a PC gamer there's is a point in time that you'll be asked to install DirectX first before the game could work. So what the hell is DirectX?

DirectX is a set of tools that provides software developers direct interface to video hardware. In addition to that it also provides API's for other multimedia devices like keyboard/mouse input and sound cards which makes it a great tool for developing games. Developing with DirectX gives you an assurance that your application will work with across different video cards and platforms (like XBox360) and the most important thing is that it's free! How cool is that? So I headed over Microsoft to download the DirectX 9.0 SDK to get my hands dirty.

There's a very good DirectX game programming Tutorial over the net. I recommend you to drop by and read the tutorials here . The website is a good jumpstart and I plan to read it throughout this study. One notable game programming resource is gamedev.net which I happen to read to get my interest going.

With the great help of the tutorials, I managed to write a code that speaks directly to my Radeon 9600! It is basically a morphing triangle that redraws in 25 frames per second. ^_^



I wrapped most of the Windows-related mumbo-jumbo stuff in functions (specially the Window creation). The code will compile as long as you added the DirectX SDK to the project. This is a very basic demonstration on how to use DirectX. The code is still in its early stages but in truth, it can be used as your default template for creating games! I added a comment in the code where you'll insert your game logic. Hurry up and download the source code!

It's been my dream to write my own game and so far I had my first step and I have a list of TODO's:

- Write a collection of classes to make my job easier
- Take a look at openGL
- Learn how to load fonts, bitmap, and 3d models in DirectX

I hope this could mutate into something interesting. When it gets to that point, I'll be sharing my code. :)

3 comments:

JP Loh said...

You might want to checkout SDL[1] too.

[1] http://www.libsdl.org/

Alvinator said...

Thanks for the comment. I happen to come across with libsdl too. I might use it in the future.

bacuzi said...

you might want to try with DirectSound and DirectShow first.