Friday, February 23, 2007

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.