glDrawArrays with specified number of vertexes per primitive

Started by
2 comments, last by Eskapade 15 years, 9 months ago
I'm currently making a rendering system for many types of objects using the VBO method. The objects may have varying numbers of vertices/object, and may also use different primitive types. If the primitive type is triangle or quad, rendering lots of these as some sort of 2d-sprite is not o problem since the start and stop-vertice is always assumed by this type of primitive type. But, when using any other type, like trianglestrip, I can't render a lots of these without them all being glued toghether. I can't sort them up in a batch of primitives since I can't specify the start and stop of each primitive object. So, did I miss something, or may this be possibly? Can I somehow tell the rendering system when using glRenderelements/glRenderArrays where the start and stops of the primitive type - like lines/trianglestrip/trianglefan - will be?
Advertisement
Sounds like you want glMultiDrawArrays/glMultiDrawElements. It's basically a macro for multiple calls to glDrawArray/glDrawElements.
Just don't use GL_TRIANGLE_STRIP. Just use GL_TRIANGLES.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
I'd suggest uploading the vertex data to the GPU, creating an index list and then using glDrawRangeElements().

This topic is closed to new replies.

Advertisement