Texturing A Large Polygon
Hi guys
When I texture a 4 pt polygon I specify the texture coordinate of the corners, so the code is like......
glBegin (GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3d ((pt1[0]), (pt1[1]), (pt1[2]));
glTexCoord2f(0.0f, 1.0f); glVertex3d ((pt2[0]), (pt2[1]), (pt2[2]));
glTexCoord2f(1.0f, 1.0f); glVertex3d ((pt3[0]), (pt3[1]), (pt3[2]));
glTexCoord2f(1.0f, 0.0f); glVertex3d ((pt4[0]), (pt4[1]), (pt4[2]));
glEnd ();
My question is this if I have a 5 pt + polygon how do I specify the texture coordinates?????
Cheers
Garreth
Same way as you would with a 4 point poly: Each tex coord should specify where on the texture the vertex is.
____________________________________________________________
www.elf-stone.com
____________________________________________________________
www.elf-stone.com
Simple formula:
U = desired_pixel_on_texture/texture_w
V = desired_pixel_on_texture/texture_h
So, say you have a 256x256 texture, and you want one of your vertices to be mapped to the point (128,32)
128/256 = 0.5
32/256 = 0.125
So your texture coordinates for that vertex are (0.5,0.125).
U = desired_pixel_on_texture/texture_w
V = desired_pixel_on_texture/texture_h
So, say you have a 256x256 texture, and you want one of your vertices to be mapped to the point (128,32)
128/256 = 0.5
32/256 = 0.125
So your texture coordinates for that vertex are (0.5,0.125).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement