Wednesday, April 18, 2007

The New NeHe Lessons

I just noticed that a beta release is available for the new NeHe lessons. You can see the release notes here.

I took a look at the code, and apart from the horrible naming convetion and the fact that they still use C++, it looks pretty good. So I've decided to do a port of them to D, but there is a catch:

* I'll only port the SDL backend
* I'll "fix" the naming convertion to something more to my tastes
* I don't know when I have the time to do this

Probably the best place to start is from the window backend so that I can get something useful done as fast as possible.

Stay tuned.

NeHe Lesson 12: Display Lists

Ok, didn't get to test this on Windows, but it should work as the lesson doesn't contain platform specific code.

First off there's an example on how to initialize a static multi-dimensional array:
(In case you didn't know already how to do it.)
/// Array For Box Colors
GLfloat boxcol[5][3] =
[
// Bright: Red, Orange, Yellow, Green, Blue
[1.0f, 0.0f, 0.0f], [1.0f, 0.5f, 0.0f], [1.0f, 1.0f, 0.0f], [0.0f, 1.0f, 0.0f], [0.0f, 1.0f, 1.0f]
];

In the module constructor we have something new.
// Enable key repeating
if ((SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL)))
{
throw new Exception("Failed to set key repeat: " ~ getSDLError());
}
Here we enable SDL to repeat key presses if you keep a key down. I've used SDL's default values for the arguments.

There isn't really anything special about the rest of the code, so grab a cola and go read what NeHe has written on the subject, here.

Here's the link to the source.

Tuesday, April 17, 2007

Linux Update

I wanted to leave a quite note on the Linux support. I tested all the current lessons on a Linux box with the following setup: Tango RC1 with DMD 1.012 and Rebuild 0.18. All of the worked fine. Found only couple typos in image filenames. Wrong case.

Plus I've pretty much done lesson 12 and I'll put it up as soon as I get home.