Tuesday, February 27, 2007

The OpenGL SDK

The OpenGL SDK has been released recently. It's not the usual thing when you think of SDKs. This time there are tutorials, libraries and links to different tools, but the most interesting feature is the inclusion of the whole reference to OpenGL version 2.1. No need to flip through the reference manual! =)

A First Glimpse at the OpenGL SDK.

The OpenGL SDK.

Monday, February 26, 2007

NeHe Lesson 09: Moving Bitmaps In 3D Space

The 9th lesson covers more ground on moving things around and applying color to black and white textures. The lesson can be read here.

This is the first time in these tutorials where we see a nice little example on how to use the D's foreach loop. It is used to initialize all the stars in the array. It is very clean looking and easy to follow. The only thing to remember in a situation like this, is to use the 'inout' modifier on the star variable so that the changes stick.

foreach (i, inout star ; stars)
{
star.angle = 0.0f;
star.dist = cast(float)i / stars.length * 5.0f;
star.r = rand.next() % 256;
star.g = rand.next() % 256;
star.b = rand.next() % 256;
}

The foreach loop is used in the drawing function also. There too the 'inout' modifier must be used because we update the values in the star at the end.

The rest of the code can be read here.

NeHe Lesson 08: Blending

The next lesson shows us how to do blending in OpenGL. It's a very cool feature even if your just doing a glass cube. :) There isn't any differences to the original work concerning OpenGL so I'll just give you couple things you could try to change in the code. Homework so to speak.

1. Change the drawing code to only apply the blending to the front and back faces of the cube.
2. Change the texture used in the other faces.

Link to the code is here.

Friday, February 23, 2007

NeHe Lesson 07: Texture Filters, Lighting & Keyboard Control

The 7th lesson adds some lights and 2 more ways to make textures. Keyboard input is added to move and rotate the box. There shouldn't be anything too difficult about the lesson. Check out the new parameters to glTexParameteri and how the lights are defined. The original lesson can be read here.

The D version is here.

All the images and other data used in these lessons can be found here.

NeHe Lesson 06: Texture Mapping

So, it's been a while. I've been very busy with other stuff lately, but I haven't forgotten this blog.

The next lesson is about texture mapping. Go read it here. There's couple things I'd like to mention about SDL and OpenGL concerning this tutorial.

First of SDL has its own image loading functions, mainly SDL_LoadBMP, which loads BMP images. In a bigger project you might want to look at SDL_image for other image types.

The other thing is that you will need to flip and rotate your textures when using SDL. The following lines of code will setup OpenGL to do that for you.

glMatrixMode(GL_TEXTURE);
glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
glScalef(-1.0f, 1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);

The full code listing can be found here.

Monday, February 19, 2007

Update: Lessons 1-5 use Tango now

I've updated the lessons 1-5 to use the Tango runtime. Only the to and from char* functions needed to be changed.

So from now on I'll publish code only compatible with Tango.

Friday, February 2, 2007

Let's dance to the Tango 0.95 beta 1

So Tango's first beta has been released. So the first thing I did, was to go and ask when and if Derelict will support it. "In the very near future."

I will be using Tango exclusively from now on because as far as I'm concerned it's far better than Phobos. That might be my Java background talking too.

I'll start of by converting the existing lessons to Tango. That shouldn't take too long, as they don't have many dependencies to Phobos. But first I have to wait for Mr. Parker to add the support to Derelict.