Hi,
I have a VBO storing a collection of polygons - i.e. triangle fans. I am willing to use glPrimitiveRestartIndex to declare when a polygon finishes and when a new one start.
I draw withGL2 gl2 = gl.getGL2();
gl2.
glEnable(GL2.GL_PRIMITIVE_RESTART);
gl2.
glPrimitiveRestartIndex(PRIMITIVE_RESTART_VALUE); // 0xffffffff
...
gl2.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL);
gl2.
glDrawElements(glGeometryType, elementSize, GL.GL_UNSIGNED_INT, firstCoordOffset);
I generate VBO with a restart value every 4 pointprotected void append(int[] hexahedronPoints, int p1, int p2, int p3, int p4) {
geometries[cursor++] = hexahedronPoints[p1];
geometries[cursor++] = hexahedronPoints[p2];
geometries[cursor++] = hexahedronPoints[p3];
geometries[cursor++] = hexahedronPoints[p4];
geometries[cursor++] = hexahedronPoints[p1];
if(DrawableVBO2.PRIMITIVE_RESTART)
geometries[cursor++] = DrawableVBO2.PRIMITIVE_RESTART_VALUE;
}
OpenGL does not consider the restart value and instead see it as a vertex.
This show a VBO fed with a closed loop p1, p2, p3, p4, p1, then p5, ... No primitive restart value is used, so OpenGL continue the line to point p5 when the loop is closed. (I am surprised to have the need to define the closing point, but anyway, the problem is mainly to see a line between p1 and p5 (which are labeled 3 and 0 in the chart).
When activating primitive restart, OpenGL simply continue reading and seem to take the value as a coordinate.