PDA

View Full Version : texture coordinate?



hwj_just
03-29-2005, 11:47 PM
I want to ask about when we make texture coordinate as this follows:

glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0,0);
glVertex3f(with,height,r);
......
glEnd();

what is the meaning of the GL_TRIANGLE_STRIP in the line glBegin()?

Thank you!

T101
03-30-2005, 12:39 AM
GL_TRIANLGE_STRIP treats the vertices as connected triangles, which means you can specify triangles with as few points as possible.
E.g. you can specify 3 triangles with just 5 vertices:


1---3---5
\A/B\C/
2---4
(The numbers represent the vertices, the letters represent the surfaces)

You need to specify a separate texture coordinate per vertex (before the glVertex call), otherwise you'll get the same texture coordinates for all vertices.

The one place where strips and fans have an influence on texture coordinates is that vertices are shared, which also means texture coordinates are shared - so you can't make a split when you use strips.
In the example above, vertex 3 has the same texture coordinates, whether you look at plane A or B or C. There are two ways to split them:
1. use GL_TRIANGLES and specify 3 coordinates per triangle

1---357---9
\A//B\\C/
24---68 ... etc
2. use multiple strips


1---35---7
\A/B\\C/ . ... etc
2---46...8