PDA

View Full Version : texture coordinates upside down



Vlasko
04-06-2004, 01:04 PM
I'm trying to make a skybox but when i load the texture in front face seems to be rotated around 180 degrees
What could be the problem?

void DrawSkybox()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,skybox_texture_id);
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f); // front face
glVertex3f(-100.0f,-100.0f,-100+my_position.z);
glTexCoord2f(1.0f,0.0f);
glVertex3f(100.0f,-100.0f,-100+my_position.z);
glTexCoord2f(1.0f,1.0f);
glVertex3f(100.0f,100.0f,-100+my_position.z);
glTexCoord2f(0.0f,1.0f);
glVertex3f(-100.0f,100.0f,-100+my_position.z);
glTexCoord2f(0.0f,0.0f); // left face
glVertex3f(-100.0f+my_position.x,-100.0f,100.0f);
glTexCoord2f(1.0f,0.0f);
glVertex3f(-100.0f+my_position.x,-100.0f,-100.0f);
glTexCoord2f(1.0f,1.0f);
glVertex3f(-100.0f+my_position.x,100.0f,-100.0f);
glTexCoord2f(0.0f,1.0f);
glVertex3f(-100.0f+my_position.x,100.0f,100.0f);
glTexCoord2f(0.0f,0.0f); // right face
glVertex3f(100.0f+my_position.x,-100.0f,-100.0f);
glTexCoord2f(1.0f,0.0f);
glVertex3f(100.0f+my_position.x,-100.0f,100.0f);
glTexCoord2f(1.0f,1.0f);
glVertex3f(100.0f+my_position.x,100.0f,100.0f);
glTexCoord2f(0.0f,1.0f);
glVertex3f(100.0f+my_position.x,100.0f,-100.0f);
glTexCoord2f(0.0f,0.0f); // back face
glVertex3f(100.0f,-100.0f,100.0f+my_position.z);
glTexCoord2f(1.0f,0.0f);
glVertex3f(-100.0f,-100.0f,100.0f+my_position.z);
glTexCoord2f(1.0f,1.0f);
glVertex3f(-100.0f,100.0f,100.0f+my_position.z);
glTexCoord2f(0.0f,1.0f);
glVertex3f(100.0f,100.0f,100.0f+my_position.z);
glTexCoord2f(0.0f,0.0f); // upper face
glVertex3f(-100.0f,100.0f+my_position.y,-100.0f);
glTexCoord2f(1.0f,0.0f);
glVertex3f(100.0f,100.0f+my_position.y,-100.0f);
glTexCoord2f(1.0f,1.0f);
glVertex3f(100.0f,100.0f+my_position.y,100.0f);
glTexCoord2f(0.0f,1.0f);
glVertex3f(-100.0f,100.0f+my_position.y,100.0f);
glTexCoord2f(0.0f,0.0f); // lower face
glVertex3f(-100.0f,-100.0f+my_position.y,100.0f);
glTexCoord2f(1.0f,0.0f);
glVertex3f(100.0f,-100.0f+my_position.y,100.0f);
glTexCoord2f(1.0f,1.0f);
glVertex3f(100.0f,-100.0f+my_position.y,-100.0f);
glTexCoord2f(0.0f,1.0f);
glVertex3f(-100.0f,-100.0f+my_position.y,-100.0f);
glEnd();
glDisable(GL_TEXTURE_2D);

}

Im using tgaloader found on nehes tutorial #6 in glut code example and init textures


void InitSkyboxTextures()
{
image_t temp_image;
glEnable(GL_TEXTURE_2D);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_RE PLACE);
glGenTextures(1,&skybox_texture_id);
glBindTexture(GL_TEXTURE_2D,skybox_texture_id);
tgaLoad("starfield_nebulax.tga",&temp_image,TGA_DEFAULT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _CLAMP_TO_EDGE);
glDisable(GL_TEXTURE_2D);
}

howie
04-06-2004, 02:58 PM
I know BMP's are saved in the order of bottom to top but I don't know if that is also true for tga files.