Wednesday, April 18, 2007

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.