How can i efficiently draw lots of movable cubes in opengl 2 (JOGL) ? do i have to construct a huge VBO/VAO that contains all cubes copies and draw in single call? or call glDraw for each instance of cube passing MVP matrix to be able to move particulaer cube? and of course cubes share same texture, vertices, normak etc. I need to achieve best performance in drawing 10000+ but with possibility to change pos of partiular cube
Asked
Active
Viewed 768 times
2 Answers
5
Use a single vbo for all cube geometry, normals etc.
Use a glsl shader that transforms the cube using a data from from an attribute VBO. (glVertexAttribPointer etc).

Wilbert
- 7,251
- 6
- 51
- 91
1
If you draw each cube individually, you are looking at a very high batch count which will perform really badly.
Using one big VBO will be the fastest but it is not good if you need to change the geometry a lot. You could possibly split the geometry into a few batches (e.g. do 1000/batch).
Maybe look into instancing or psuedo instancing as another option. http://www.gamerendering.com/2008/10/21/instancing/

Pete
- 4,784
- 26
- 33
-
I'm not sure if JOGL 2.0 supports ARB_instanced_arrays extension – user1338830 Dec 10 '12 at 13:30
-
As i understood instancing still requires 1 draw call per cube? – user1338830 Dec 10 '12 at 15:02
-
No instancing doesn't have 1 draw call per cube. "This extension provides the means to render multiple instances of an object with a single draw call, and an "instance ID" variable which can be used by the vertex program to compute per-instance values, typically an object's transform." – Pete Dec 10 '12 at 18:51