I am trying to texture a cuboid in legacy OpenGL. No matter which side of the cuboid I render first, this side is not textured correctly where as all other sides are textured correctly. I have tried rendering different sides of the cube first.
This is the code that draws the cube including it's texture coordinates:
void Objects::cuboidTextured(float width, float height, float depth, float xpos, float ypos, float zpos, float r, float g, float b){
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(xpos, ypos, zpos);
glColor3f(r, g, b);
glBegin(GL_QUADS);
glVertex3f( width, -height, depth );
glTexCoord2f(1,0);
glVertex3f( width, height, depth );
glTexCoord2f(1,1);
glVertex3f( -width, height, depth );
glTexCoord2f(0,1);
glVertex3f( -width, -height, depth );
glTexCoord2f(0,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f( width, -height, -depth );
glTexCoord2f(1,0);
glVertex3f( width, height, -depth );
glTexCoord2f(1,1);
glVertex3f( width, height, depth );
glTexCoord2f(0,1);
glVertex3f( width, -height, depth );
glTexCoord2f(0,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f( -width, -height, depth );
glTexCoord2f(1,0);
glVertex3f( -width, height, depth );
glTexCoord2f(1,1);
glVertex3f( -width, height, -depth );
glTexCoord2f(0,1);
glVertex3f( -width, -height, -depth );
glTexCoord2f(0,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f( width, height, depth );
glTexCoord2f(1,0);
glVertex3f( width, height, -depth );
glTexCoord2f(1,1);
glVertex3f( -width, height, -depth );
glTexCoord2f(0,1);
glVertex3f( -width, height, depth );
glTexCoord2f(0,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f( width, -height, -depth );
glTexCoord2f(0,1);
glVertex3f( width, -height, depth );
glTexCoord2f(0,0);
glVertex3f( -width, -height, depth );
glTexCoord2f(1,1);
glVertex3f( -width, -height, -depth );
glTexCoord2f(1,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f( -width, -height, -depth);
glTexCoord2f(1,0);
glVertex3f( -width, height, -depth);
glTexCoord2f(1,1);
glVertex3f( width, height, -depth);
glTexCoord2f(0,1);
glVertex3f( width, -height, -depth);
glTexCoord2f(0,0);
glEnd();
glPopMatrix();
}