Archived

This topic is now archived and is closed to further replies.

welshgaz

Texturing A Large Polygon

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites