Thursday, March 22, 2007

Small Update

I've gone through all the existing lessons and updated them to Tango beta2 and DMD 1.009. They work at least on my Windows box, but I'm having some troubles with my Linux laptop. I'll give an update when and if I get them to work on Linux too.

I also changed the links in the first five lessons to point to the source code directly and not zip files.

Wednesday, March 14, 2007

Status Update

Sorry for not posting anything for a while. I've just started this Monday in a new job at Digital Chocolate! At last got into a game company. =) My new job title is Tools Programmer, which suits me just fine. It's been great and I look forward to many interesting days ahead.

I also have other stuff going on, so it will probably be a while before I get the next lesson done.

Tuesday, March 6, 2007

NeHe Lesson 11: Flag Effect (Waving Texture)

Got the next one ready at last. This one shows you how to do a flag effect. The only hard part should be the math for calculating the wave. Go read Bosco's explanation here.

I'll add the only new D bit in the code. I've used a nice way to initialize a dynamic multi-dimensional array.

First we have at the top of the module the declaration:

GLfloat[][][] points;

Then in initGL we initialize the array, like this:

points = new GLfloat[][][](45, 45, 3);

Then we just loop through the indices and assign values to them.

Here's the whole code, and here's the flag texture.

Thursday, March 1, 2007

NeHe Lesson 10: Loading And Moving Through A 3D World

The 10th lesson is finally converted and polished. This lesson shows you how to load world data from a text file and then how to display it. And actually it's pretty simple code. The original lesson can be read here. I'll go over couple things here that are more specific to D and Tango.

First I've imported the world data at compile time into the final executable. This is a cool feature and I think very useful for static data like this. You can of course use it to import texture data or something totally different.

setupWorld(import("world.txt"));
You need at least the version 1.005 of DMD for this to work. I have no idea if GDC even supports this yet. With 1.005 you need to add the relative path to the world.txt to the string above. With 1.006 and later you don't need to change the code, but you must use the -J switch to define the search path for the compiler where it can find the file.

The setupWorld function is pretty simple. With the use of Tango's LineIterator, reading through the world data is a breeze.

Now go play with it, lesson10.d and world.txt.