# Texture mapping. Why are the sides of the cube mapped like that in lesson 6

This topic is 4977 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I don't understand why NeHe texture maps the cube the way he does in lesson 6. Shouldn't every side of the cube have the texture facing the right way? Why is it that if the cube spins on the Y axis, not all the textures on each side face right side up. Here's an example. He does this:
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
// Back Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
Why doesn't he do the back face bottom right, and then bottom left? Why does it always start at a different point? I thought the back face was just the front face but it's drawn in relation to us seeing the "back" of it because we drawing from the front.

##### Share on other sites
IT is like this because in order to flip it in the correct orientation you have to reverse the winding order of the vertics(from 1234 to in this case 1432), the textures allso need fliping.

So if you take the front face, switch possition on line 2 and 4, change the z coordinate to -1 on all of them, and finaly flip the u coordinate(1 becomes 0 and 0 becomes 1), then you will see that it fits just perfectly.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015751
×