Jump to content
  • Advertisement

Archived

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

Pontius

What Texture Coords are Needed for a Triangle?

This topic is 5686 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

I am rendering a terrain as a bunch of triangles that share vertices (I know it should be triangle strip, but it''s triangles for now). I ultimately want to lay one big image over the terrain. I''ve seen lots of examples that show how to supply tex coords for a square, but few for triangles. For examples, I have something similar to the following for each triangle: Vertex v1, v2, v3; glTexCoord2f(???); glVertex3f(v1.x, v1.y, v1.z); glTexCoord2f(???); glVertex3f(v2.x, v2.y, v2.z); glTexCoord2f(???); glVertex3f(v3.x, v3.y, v3.z); I am unsure which values should be given to the tex coords for each vertex? Does there even need to be a glTexCoord2f call for each vertex? Is it supposed to be the actual location on the screen that the vertex is? Or some value between 0 and 1? Please help clear this up. Thanks

Share this post


Link to post
Share on other sites
Advertisement
a tex coord is a texture coordinate. It is the coordinate on the bitmap of the texture that you are applying to your mesh. as such you don't need them if you aren't doing texture mapping. numbers range from 0..1. think of them as x/y coordinates on your bitmap. 0 = one side 1 = the other. so if you have a mesh of 2 triangles like so:


V1 ------ V2
| / |
| / |
| / |
| / |
|/ |
V3 ------ V4


the tex coords would be:

V1: 0,0
V2: 1,0
V3: 0,1
V4: 1,1

so each time you use V2 and V3 (once for each of the two triangles) you re-enter the same texCoords as you did before

[EDIT: for more info read the openGL redbook chapter 9: Texture Mapping -> viewable in your favorite browser at: http://fly.cc.fer.hr/~unreal/theredbook/ ]

-me

[edited by - Palidine on January 22, 2003 5:50:31 PM]

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!