Use vertex arrays in JOGL backend

From JReality Wiki
Revision as of 17:54, 6 March 2009 by Gunn (Talk | contribs)

(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Source file: GLVertexArrayExample


Run as Java webstart


This example is provided to show how to activate the use of vertex arrays for rendering in the JOGL backend. The basic code is similar to that of Use a GLSL Shader:


 
dgs.createPolygonShader("glsl");


But in this case we don't set an instance of GlslProgram as in that example. The default behavior of the GlslPolygonShader is to use vertex arrays instead of display lists when rendering. When no GlslProgram is provided, it implements a generic subset of the behavior of DefaultPolygonShader.


Note that

  • the GlslPolygonShader does not implement all the features of the DefaultPolygonShader, so it can only be used for generic situations where these features are not needed.
  • It is also not possible to force the point and line shaders to use the GlslPolygonShader to render spheres and tubes since these are always created using display lists in the current implementation of the JOGL backend.


In this tutorial example you can switch back and forth between the default shader and the GLSL shader.

  • Type the '1' key to toggle between vertex arrays non-vertex arrays.
  • Type the '2' key to toggle use of display lists (only valid in the non-vertex array case).


Additionally, the example comes with an instance of de.jreality.jogl.InfoOverlay which prints statistics on the frame rates obtained. The fields include:

  • Memory Usage
  • Polygon Count: (only reliable for non vertex-array case)
  • Clock FPS: frames per second measured on the clock
  • Real FPS: frames per second based on render() method ONLY


Sample performance (Clock FPS) on my machine:

  • with display lists: 210 FPS
  • without display lists: 20 FPS
  • vertex arrays: 80 FPS


From this you can see that display lists are faster than vertex arrays by a factor of 2.5, but vertex arrays are faster than not using display lists by a factor of about 4. So, if your geometry doesn't change continuously you're better off using display lists than vertex arrays.


Would be interested to hear of other measurements. Post on this forum thread..


Previous: Use a GLSL Shader Developer Tutorial: Contents Next: Use the root appearance