Question

How to draw several separate lines using a single VBO?

Was it helpful?

Solution

glDrawElements(GL_LINES, ..., ..., ...);

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top