OpenGL – Generating a Plane with One Triangle Strip

opengl

I would like to follow up on this question, except that I have no code to show, so I decided to ask it here.
In the linked question, the OP was looking for an algorithm which could generate a plane with only one OpenGL triangle strip. He came up with a solution that works almost perfectly:

The order of the vertices for the strip is indicated by the arrows: 1-5-2-6-3-etc.
The only drawback is that it also generates one unnecessary triangle on every pair of rows (on the picture: triangles 4-8-12 and 5-9-13).

In the OP's case, it was not so much of a problem: since his plane was flat, there would only be a few artifacts on the very edge of the grid. However, I want to draw a torus (how are planes and tori related: when you "unfold" a torus, you get a flat surface divided in quadrilaterals). Where the OP in the previous question would only have a few artifacts on some edges, I would have full triangles crossing the surface of the torus. 🙁

I tried to think of other solutions like this one, which is very similar:

But with this one, instead, triangles 7-4-12 and 10-5-13 are drawn twice.

The easiest, fail-proof solution that I know will work is the one where triangles are stripped separately from every row:

However, I am afraid of performance issues, and it would be unfunny to go with such a solution.

Instead, is there a way to strip all the triangles from the plane in one go, and without unnecessary or double triangles?
Thank you for your time!

Best Answer

OpenGL has Primitive Restart functionality for drawing multiple triangle strips. The idea behind this extension is to use a special index value to indicate that a new strip is to be started after that index.