Cube with triangle strips and vector normals in openGL

Eric Brotto picture Eric Brotto · Nov 11, 2010 · Viewed 7.3k times · Source

I'm trying to create a cube using one series of vertices such as attempted in this example (which I believe is wrong) and also talked about on this forum. The answer I'm looking for should look something like this:

 1,  1, -1
-1, -1, -1,
 1,  1,  1

... and so on. I'm hoping to get this down to a minimum of 13 vertices (6 sided cube = 12 triangles).

Is this possible?

Answer

Kos picture Kos · Nov 13, 2010

There's little benefit in minimizing the vertices of a triangle / quad strip. One advantage of having each face has its own vertex (for a sharp-edged mesh like the cube) is the ability to specify different normal to each vertex, which might might be important for you if you want to have correct per-pixel lighting with a specular reflection.

(Anyway, if you're not concerned about normals or anything: The best you can do in terms of sheer efficiency is specify just the 8 vertices and use an index array. This enables the use of vertex cache so your vertex shader is likely to run only once per each vertex, even though it is used by several faces).