Reputation: 3521
How to draw several separate lines using a single VBO?
Upvotes: 9
Views: 5230
Reputation: 162367
In OpenGL-3.1 and later there's a functionality called primitive restart. It works by specifying a special vertex array element index that causes the current primitive to be restarted. That way a single element array allows to draw several GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, GL_QUAD_STRIP.
http://www.opengl.org/sdk/docs/man4/xhtml/glPrimitiveRestartIndex.xml
This is largely based on the NV_primitive_restart extension: http://www.opengl.org/registry/specs/NV/primitive_restart.txt
Apart from that you can use a primitive type in which vertices are not shared and blow up the element index array a bit.
Upvotes: 8