|
-
Jul 31st, 2006, 10:00 AM
#2
Thread Starter
Lively Member
Re: How to texture map a triangle using OpenGL?
This is a code snippet for the texture mapping and vertices for the wall. So far it works fine.
glBindTexture(GL_TEXTURE_2D,texture[2]);
glBegin(GL_QUADS); //Front Right
//Front face
glTexCoord2f(0.0f,0.0f); glVertex3f(2.0f,7.0f,5.0f); //Bottom left
glTexCoord2f(1.0f,0.0f); glVertex3f(6.0f,7.0f,5.0f); //Bottom right
glTexCoord2f(1.0f,1.0f); glVertex3f(6.0f,11.0f,5.0f); //Top right
glTexCoord2f(0.0f,1.0f); glVertex3f(2.0f,11.0f,5.0f); //Top left
........
glEnd();
But when I use texture mapping on the triangular roof, the texture map is applied to the walls as well.
glBindTexture(GL_TEXTURE_2D,texture[3]);
glBegin(GL_POLYGON); //Front right
//Front face
glTexCoord2f(0.0f,0.0f); glVertex3f(2.0f,11.0f,5.0f); //Bottom left
glTexCoord2f(1.0f,0.0f); glVertex3f(6.0f,11.0f,5.0f); //Bottom right
glTexCoord2f(0.5f,1.0f); glVertex3f(4.0f,14.0f,2.5f); //Top
......
glEnd();
I matched the tex coordinates with the vertex coordinates but I don't know why the triangle's texture will override the texture of the wall.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|