PDA

View Full Version : Texturing problem



weebull
03-09-2003, 04:34 PM
I am trying to create a skybox and make the floor texture tile. This code should work but it results in a dodgy shade of grey n no texture.



// Build A Texture From The Data
glGenTextures(1, &texture[0].texID);

glBindTexture(GL_TEXTURE_2D, texture[0].texID);
//make the texture repeat for the desert floor
if(strcmp(filename, "images/desert_dn2.tga") == 0)
{
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _REPEAT);
}else {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if (texture[0].bpp==24)
{
type=GL_RGB;
}

glTexImage2D(GL_TEXTURE_2D, 0, type, texture[0].width, texture[0].height,
0, type, GL_UNSIGNED_BYTE, texture[0].imageData);

shinpaughp
03-09-2003, 08:37 PM
Either you haven't enabled GL_TEXTURE_2D or a OGL function is erroring and just updates the error code, but continues. If you have enabled GL_TEXTURE_2D then declare 2 variables as

GLuint err;
char* errstr;

call the following after glTexImage2D. Also, use breakpoints in your debugger and check each of your variables that are being passed to glTexImage2D.

err = glGetError();
if (err)
errstr = gluErrorString(err);

Just some ideas...

gator
03-10-2003, 02:13 PM
Why use glTexParameterf when you can use glTexParameteri?

GL_LINEAR is not a float value, although I don't think this matters
much or has to do with your problem.