I recently ported my group’s very performance-intensive rendering system from GL4Java to JOGL. Having experienced a serious decrease in the performance of vertex arrays after the switch, I’ve been migrating the code over to use VBO’s. However, I have not yet been able to attain adequate frame rates for our needs.
All of the objects I’ve been rendering are in the form of stripped geometry, so the code to draw a single object is currently:
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, vbo.id); //data vbo
gl.glVertexPointer(3,GL.GL_FLOAT,0,BufferUtils.bufferOffset(0)); //data is generally organized in buffer as (vertices[0-n],texcoords[0-n],colors[0-n])
gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, vbo.indexID); //all the indices for all the strips
//then, since not all of the strips use the same primitive type, there's a loop
for (int n = 0; n < vbo.stripTypes.length; n++){
gl.glDrawRangeElements(vbo.stripTypes[n],
0,vbo.elementEnd,
vbo.capacity[n], //the length of the current strip
GL.GL_UNSIGNED_INT,
vbo.offset[n]); //an array of ByteBuffers preloaded with output from BufferUtils.bufferOffset
}
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);
gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
The models we’re drawing range from 6k faces to 40k faces. In some of the projects, we are able to use static VBO’s, but in many cases, we dynamically deform the geometry, and thus use streaming VBOs.
In the old GL4Java code, we were able to get suitable performance by using display lists of vertex array rendered geometry for static geometry, and just vertex arrays for the dynamic geometry. However, in the new VBO-based JOGL code, vertex arrays are unbearably slow for the deforming geometry (like 12fps for one model, when I need to draw dozens), and VBO’s and DisplayLists don’t seem to play well together (the displaylist performance tanks).
Unfortunately, removing display lists entirely, and trying to render absolutely everything as VBO’s does not reach our performance needs. Running -Xprof reveals that 70% of the time is spent in dispatch_glDrawRangeElements .
Any recommendations on what I may be doing wrong, or what I can do to improve performance?