An alternative to triangle strips and triangle fans
Triangle strips and triangle fans are very useful because they help reducing the number of vertices to send through the pipeline.
Rendering n triangles with GL_TRIANGLES requires 3*n vertices.
Rendering n triangles with GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN requires n+2 vertices.
I think there could be an alternative to triangle strips or triangle fans that would also require n+2 vertices to render n triangles, but would pick vertices in a different order.
Let's call it "alternated triangle strip", using the token GL_TRIANGLE_STRIP_ALT. The name and token are subject to change.
An alternated triangles strip is the same as a triangle strip except the fact that the shared vertices are not always the last two processed vertices. They alternate between the "last two processed vertices (ie the last processed vertex with the second last processed vertex)" and "the last processed vertex with the third last processed vertex".
Example of processing :
glBegin(triangle_primitive);
glVertex(v1);
glVertex(v2);
glVertex(v3);
glVertex(v4);
glVertex(v5);
glVertex(v6);
glVertex(v7);
glVertex(v8);
glVertex(v9);
glEnd();
Triangles rendered with triangle_primitive == GL_TRIANGLES :
triangle1 = (v1 v2 v3)
triangle2 = (v4 v5 v6)
triangle3 = (v7 v8 v9)
Triangles rendered with triangle_primitive == GL_TRIANGLE_FAN :
triangle1 = (v1 v2 v3)
triangle2 = (v1 v3 v4)
triangle3 = (v1 v4 v5)
triangle4 = (v1 v5 v6)
triangle5 = (v1 v6 v7)
triangle6 = (v1 v7 v8)
triangle7 = (v1 v8 v9)
Triangles rendered with triangle_primitive == GL_TRIANGLE_STRIP :
triangle1 = (v1 v2 v3)
triangle2 = (v2 v3 v4)
triangle3 = (v3 v4 v5)
triangle4 = (v4 v5 v6)
triangle5 = (v5 v6 v7)
triangle6 = (v6 v7 v8)
triangle7 = (v7 v8 v9)
Triangles rendered with triangle_primitive == GL_TRIANGLE_STRIP_ALT :
triangle1 = (v1 v2 v3)
triangle2 = (v2 v3 v4)
triangle3 = (v2 v4 v5)
triangle4 = (v4 v5 v6)
triangle5 = (v4 v6 v7)
triangle6 = (v6 v7 v8)
triangle7 = (v6 v8 v9)
As a matter of usefulness, you can see that a torus can be rendered with a single "alternated triangle strip", which is obviously better (less vertices passed through the pipeline) than rendering a few adjacent quad strips.
Though, it is already possible to render a torus with a single _classic_ triangle strip.
Anyway, does any of you know how to render a cube with a single triangle fan, triangle strip or quad strip ? I don't (at least I don't think it's possible without degenerated polygons). In my opinion you need at least two triangle fans, two triangle strips or two quad strips to render a cube. But it is possible to render a cube with a single alternated triangle strip, quite easily.
Though, this time again it is already possible to render a cube with a single classic triangle strip. The difference between the triangle strip method and the alternated triangle strip method is that I find it much obvious to render a cube with a single alternated triangle strip than with a single classic triangle strip, although I know it's just a matter of preference.
If you want to render a cube with 4 faces -- 2 adjacent faces being holes -- it's still obvious to do it with an alternated triangle strip, but I don't know if it's possible to do it with a classic triangle strip (I'm convinced it's not possible, but I haven't studied this case enough to confirm what I'm saying).
All of that to tell that I can't prove that alternated triangle strip offer a unique rendering method (that is, I can't prove that there exists a mesh that can be rendered with a single alternated triangle strip and not with a single classic triangle strip) but I can affirm it offers a new dimension for rendering order.
In that sense, including GL_TRIANGLE_STRIP_ALT (or whatever its name) into OpenGL specifications (or an extension) would be no more no less useful/efficient than the primitive GL_QUAD_STRIP is, since I can admittedly affirm that everything rendered by quad strips can be rendered by classic triangle strips (with the same pipeline throughput).
As a final note, such processing could be extrapolated to GL_QUAD_STRIP_ALT.
(c) Vincent David 2002 - All rights reserved !
[This message has been edited by vincoof (edited 09-02-2002).]
Re: An alternative to triangle strips and triangle fans
don't studied all what you said, but it seems that you want to add another way to do a n+2 array for n triangles !!!
I think strip are already very more often used than fan, so, maybe it will be difficult to you to prove your veracity...
One way, I think would be to find (but it's still impossible), a simple algorithm that could hands N+2 vertices for N triangles.
Re: An alternative to triangle strips and triangle fans
Nice http://www.opengl.org/discussion_boards/ubb/smile.gif
multi_draw_arrays (or so ...) combined with clever post transform-caching will probably make it pointless, but it's still nice http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Re: An alternative to triangle strips and triangle fans
Quote:
One way, I think would be to find (but it's still impossible), a simple algorithm that could hands N+2 vertices for N triangles.
That is what a triangle fan does, that is what a triangle strip does and that is what an alternated triangle strip does too.
Or maybe I misunderstood your sentence.
Re: An alternative to triangle strips and triangle fans
Just in order to explain what I mean by "I find it much obvious to render a cube with a single alternated triangle strip than with a single classic triangle strip", here's how a cube can be rendered with a single GL_TRIANGLE_STRIP_ALT :
Quote:
Code :
(13)+----+(14)
|\ |
| \ |
| \ |
(10)| \|
(9)+----+----+(12)
|\ |\ |
| \ | \ |
| \ | \ |
(6)| \| \|
(5)+----+----+----+(11)
|\ |\ |(8)
| \ | \ |
| \ | \ |
| \| \|
(2)+----+----+(7)
|\ |(4)
| \ |
| \ |
| \|
(1)+----+(3)
and here's how a cube can be rendered with a single GL_TRIANGLE_STRIP :
Quote:
Code :
+(14)
/|
/ |
/ |
(12)/ |
(10)+----+----+(13)
/|\ | /
/ | \ | /
/ | \ | /
/ | \|/
(8)+----+----+(11)
|\ |(9)
| \ |
| \ |
(6)| \|
(4)+----+----+(7)
/|\ | /
/ | \ | /
/ | \ | /
/ | \|/
(2)+----+----+(5)
| /(3)
| /
| /
|/
(1)+
Still, it's a matter of preference, but I really think the first one is easier.