#### Archived

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

# What Texture Coords are Needed for a Triangle?

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

## 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 on other sites
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

-me

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