GL_TRIANGLE_STRIP and texcoord

Started by
3 comments, last by juglar 16 years, 10 months ago
Hi guys!! y have the follows vertex to draw a square with triange strip, when i try to put the textcoord i get bat texture mapping, can anyone tell me what are the textcoord for this vertes liste in GL_TRIANGLE_STRIP txs in advance! vtx1: x: 0 y: 10 z: 0 vtx2: x:0 y:10 z:10 vtx3: x:10 y:10 z:0 vtx4: x:10 y:10 z:10
Advertisement
The texture coordinates depend on how you want them to be mapped..

I guess you want vtx-1 to be the lower left corner of the texture image.
Your strip looks like that, when you look at it from above, cause its a square lying on the x-z-plane.

vtx3 -----> vtx4  ^    |       |          |             |vtx1 -----> vtx2


Sorry, the diagram is ugly [lol]

The texture coordinates now have to be set up so that the texture is mapped onto the strip in the right order, and that is:
vtx1 - glTexCoord2f( 0.0f, 0.0f );
vtx2 - glTexCoord2f( 1.0f, 0.0f );
vtx3 - glTexCoord2f( 0.0f, 1.0f );
vtx4 - glTexCoord2f( 1.0f, 1.0f );
Hi! i draw the Trigles strip in that way (ignore de dots)

vtx2.........vtx4
^ |..........|^
|....|.......|
|.....|......|
|......|.....|
|.......|... |
|..........|.|
vtx1.........vtx3

te secuense is lije this: vtx1--> vtx2-->vtx3-->vtx4


that is the order i have now ... and i can't figure out how to put the corretct texture mapping coord :( can you help me?

txs! in advance
PS: My draw is worst!:P
Hey,

textures are mapped onto a rectangle(as this is one) as if you'd glue them onto the vertices. A texture has coordinates in x and y direction (which are then calles s and t or u and v) like this:
 t  ^1.0 |    |    | heres the image..    |    |0.0 |________________>   0.0            1.0 s


That means if you put that onto your triangle strip it looks like that
 t  ^1.0 | vtx2.........vtx4    |  ^ |..........|^    |  |....|.......|    |  |.....|......|    |  |......|.....|    |  |.......|... |    |  |..........|.|0.0 |  vtx1.........vtx3    --------------------->      0.0           1.0  s


So here you are (first parameter is s, second t):
vtx1 - glTexCoord2f( 0.0f, 0.0f );
vtx2 - glTexCoord2f( 0.0f, 1.0f );
vtx3 - glTexCoord2f( 1.0f, 0.0f );
vtx4 - glTexCoord2f( 1.0f, 1.0f );
txs! folks!

This topic is closed to new replies.

Advertisement