Tuesday 11 December 2007

DirectX Demo Project

Here is my DirectX demo project for Games Programming course at Abertay.

It makes use of:
- A point light and a directional light
- Shadows (planar)
- Animated meshes



And it's the url:
http://www.youtube.com/watch?v=xI8r653mX4U

Now I'm going to start to study for my Maths exam :)

Sunday 9 December 2007

How to print text in directx

First, you need to create a RECT object to set the area on screen, ID3DXFont object, and a D3DCOLOR object:

RECT lineRect;
ID3DXFont * pDefaultFont;
D3DCOLOR defaultFontColor;


This is how to initialise them:

A rectangle which has a height of 50px, on top of screen:
lineRect.left = 0;
lineRect.top = 0;
lineRect.right = 1024;
lineRect.bottom = 50;


How to create a font
D3DXCreateFont(Device, 30/*fontHeight*/,
0, FW_BOLD, 0, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
TEXT("Calibri"), &pDefaultFont );


I'm not going to deal with the details of D3DXCreateFont method, but you can find the reference here:
http://msdn2.microsoft.com/en-us/library/bb172773.aspx

How to set the color:
defaultFontColor = D3DCOLOR_ARGB(255, 255, 255, 255);

Now you can write your text:
pDefaultFont->DrawTextA(NULL, "My Text Here", -1, &lineRect, DT_RIGHT, defaultFontColor);

Sometimes I strongly miss the VB6 times:
Print "my text here"
But of course, they're "incomparable" in terms of speed :)