I would like to draw many cubes however when I get to around 100 it starts to slow the frame rate down. Is there a way I can make a single draw call to open gl to draw them instead of making a drawelements call for every cube. The only difference between the cubes would be position and color.
Well, if you’re getting unacceptable slowdown when only drawing 100 cubes, it’s likely your system is too slow for any other alternative to work. And even if these are screen-sized cubes that perform lots of shader computations per-vertex and per-fragment, there’s not much you can do.
Though to be honest, if you’re getting slowdown with only 100 cubes, the first thing I’d check is to see if you’re getting a hardware OpenGL rendering context.
Yeah if you situated too close to the cube then your card has to fill in allot of pixels, and this can slow things down due to your card having hit it’s pixel fill rate, but this is only a case when lots of cubes overlap repeatedly. Also make sure back face culling is enabled, don’t want to be drawing things that are not facing you
You can also use geometry instancing. You need to know how to write shaders though. Googling it should get you started.
Cards that support it…
GeForce 6000 and up (NV40 GPU or later)
ATI Radeon 9500 and up (R300 GPU or later).
Basically DirectX 9.0c / OpenGL 2.1 upwards, which is almost every card in use today
You can instance geometry and specify position and colour for each instance. There are a number of ways to active this which you can lookup; geometry shaders, uniform buffer objects, texture buffer objects and instances arrays.
Quite honestly unless you are drawing tens of thousands of objects none of these are going to speed up your app. Seeing as you are struggling to draw ten then nothing is going to improve that.