do u have any sample code i m begiiner in open glSay you've got 2 strips, strip 1 has vertexes 0, 1, 2, 3 and strip 2 has vertexes 4, 5, 6, 7. To render them with GL_TRIANGLES you use indexes 0, 1, 2, 1, 3, 2, 4, 5, 6, 5, 7, 6 for your glDrawElements call. No need to make any changes to the vertexes. That'll do it.
The number of indexes you need for each strip is always (numverts - 2) * 3 and just remember to follow the winding order rules, reversing the order for alternate tris that make up the strip. Code for writing out indexes might look something like this:for (int i = 2; i < stripverts; i++) { indexes[totalindexes++] = totalverts + i - 2; indexes[totalindexes++] = (i & 1) ? (totalverts + i) : (totalverts + i - 1); indexes[totalindexes++] = (i & 1) ? (totalverts + i - 1) : (totalverts + i); } totalverts += stripverts;
Then just ensure that all of your vertexes for all strips are in a single big array (or single VBO, as appropriate) and your draw call is:glDrawElements (GL_TRIANGLES, totalindexes, GL_UNSIGNED_WHATEVER, indexes); // _WHATEVER is _SHORT or _INT, replace indexes with 0 for a VBO
OK, it's more indexes, but indexes are much smaller than full vertexes, the duplicate vertexes will be in your cache and so won't need to be retransformed, and you'll find that the overall submission is lighter than with degenerate triangles.
- Viewing Profile: Posts: glxy
Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics
Community Stats
- Group Members
- Active Posts 2
- Profile Views 154
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
Posts I've Made
In Topic: Quick confirmation on Triangle Strips / Degenerate Triangles
28 September 2012 - 01:01 AM
In Topic: Quick confirmation on Triangle Strips / Degenerate Triangles
28 September 2012 - 12:53 AM
any one have sample code for triangle strip
- Home
- » Viewing Profile: Posts: glxy

Find content