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.
© Vincent David 2002 - All rights reserved !
[This message has been edited by vincoof (edited 09-02-2002).]