I’m currently using glMultiDrawElements rendering arrays directly:
glPushMatrix();
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer(3, GL_FLOAT, 0, verts);
glMultiDrawElements(GL_LINE_STRIP, globalIndexCount, GL_UNSIGNED_INT, (const void **) &globalIndices[0], globalIndices.size() );
glDisableClientState( GL_VERTEX_ARRAY );
glPopMatrix();
To get better performances, I’d like to render the elements with VBO’s: I think buffer are properly initialized and bind, but I can’t figure out how the glMultiDrawElements call should look like.
The one posted below doesn’t work, anybody can help please?
// bind buffers
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, fullHairCounter*HAIRPOINTS*sizeof(vector3_t), verts, GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, iboId);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, globalIndices.size() *sizeof(unsigned int), (const void **) &globalIndices[0], GL_STATIC_DRAW_ARB);
// render buffers
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, iboId);
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer(3, GL_FLOAT, 0, verts);
glPushMatrix();
glMultiDrawElements(GL_LINE_STRIP, NULL, GL_UNSIGNED_INT, (const void **) &globalIndices[0], NULL );
glPopMatrix();
glDisableClientState( GL_VERTEX_ARRAY );
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
Thanks for any help.