Why is the texture not working?

I realize that this may be kind of a dumb problem, but here it is:

I’m trying to texture a cube, which is made of 6 quads. I’m pretty sure that I’ve got the texure coordinates correct, and I think it can find the texture file, because I have it set up to to give an error if it can’t for some reason.

It compiles just fine, and will use colored vertices, but it if I try to bind the texture to it, the cube comes out white. I did remember to turn on texture mapping, so I’m not sure what else to try. Is there a special .lib file in need to link, or a special bitmap format it needs?

If it turns white, that usually means that there was an error loading the texture.

This can be anything from invalid pointers to data, to non-power-of-2 texture sizes.

Use glGetError() to get an idea of what is going wrong.

j

I had that same problem a while back. My solution was that I had forgotten to enable textures via glEnable. If you are using NeHe’s code it is glEnable(GL_TEXTURE_2D);

This could be the standard OpenGL default mipmap problem.
OpenGL texture parameter defaults for minification filtering is GL_LINEAR_MIPMAP_NEAREST, so if you don’t load all levels of the texture you get no texture applied.
Set the GL_TEXTURE_MIN_FILTER to GL_LINEAR or GL_NEAREST and see if it works.

I also think you must set wrap-modes.

Do so with

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

, unless you already did it