Jump to content
  • Advertisement

Archived

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

welshgaz

Texturing A Large Polygon

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

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!