Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most efficient way to draw multiple identical objects?

I would like to make a game out of many cubes and am planning on putting it on mobile platforms and also on the web using webgl. My problem is when I make a drawelements call per cube I take a hit on the frame rate. Is there a way I can make a single draw call to opengl es to draw them? The only difference between the cubes would be position and color.

like image 480
Xavier Avatar asked Sep 26 '10 17:09

Xavier


1 Answers

I ran into same problem myself. I asked similar question and answered it myself yesterday. Take a look at:

Efficient way of drawing in OpenGL ES

You want to create your vertex buffers and upload them to graphics card memory only once using gl.bufferData. Then use reference to that buffer each time you do gl.drawElements or gl.drawArrays. Until the next time the content of your 3D scene changes, you can use this buffer that is uploaded in graphics card memory.

like image 173
Jayesh Avatar answered Oct 19 '22 23:10

Jayesh