#### Archived

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

# texures on a triangle strip

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

## Recommended Posts

Hi there... Ho do I pass coordinates of texure to a triangle strip which I draw in a loop. Every loop, I draw only two new points (vertics), but I need 4 to texure map my image... Good solution, anyone? thx

##### Share on other sites
If you wanted to stretch the texture across the entire strip you can do this:

float NUMCOLS = (however many);

...

glBegin(GL_TRIANGLE_STRIP);
for (float c = 0; c < NUMCOLS; c++) {
glTexCoord2f(c/NUMCOLS, 0.0f);
glVertex3f(...);
glTexCoord2f(c/NUMCOLS, 1.0f);
glVertex3f(...);
}
glEnd();

So at the beginning of the strip, c = 0, so c/NUMCOLS = 0.0 (the left edge of the texture).
At the end of the strip, c = NUMCOLS, so c/NUMCOLS = 1.0 (the right edge of the texture).
Everything else in between is a fraction between 0 and 1.

----------------------------------------------------------------

If you want to tile the texture you could do this:

...

glBegin(GL_TRIANGLE_STRIP);
for (int c = 0; c < NUMCOLS; c++) {
int u = (c % 2);
glTexCoord2i(u, 0);
glVertex3f(...);
glTexCoord2i(u, 1);
glVertex3f(...);
}
glEnd();

% returns the remainder.
So, every time c is even, c % 2 = 0 (left edge of texture).
Every time c is odd, c % 2 = 1 (right edge of texture).

thx

1. 1
Rutin
25
2. 2
3. 3
JoeJ
19
4. 4
5. 5

• 10
• 11
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
631752
• Total Posts
3002095
×