Texturing A Large Polygon

Started by
2 comments, last by welshgaz 21 years, 11 months ago
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
University of Bristol student doing a Masters in Computer Science
Advertisement
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 | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

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).
Thanks Guys Its Worked!
University of Bristol student doing a Masters in Computer Science

This topic is closed to new replies.

Advertisement