I am trying to understand what is difference between multidraw and draw command?
According to this page, Vertex Rendering - OpenGL Wiki, “Multi-draw is useful for circumstances where you know that you are going to draw a lot of separate primitives of the same kind that all use the same shader”. So if we change the shader we need to do another draw command.
But what if we try to render 2 triangles that uses same shader? why can’t we put all the vertices in a VBO and use glDrawArray rather than glMultiDrawArray?
Is it illegal to combine the 2 triangle vertices? if not, do we gain any performance by using Multidraw rather than the single draw?
[QUOTE=GClements;1284475]glMultiDrawArrays() allows you to draw multiple disjoint ranges rather than a single range.
This allows you to enable and disable portions of the geometry without having to either rebuild the attribute arrays or use multiple calls.[/QUOTE]
So if it is disjoint I cannot use a single draw command?
And what is performance drawback of using draw command. I mean if we want to bind different VBOs what happens in the hardware? do we need to fetch anything from CPU memory or …?
You can, you just have to define your indices. See this for example.
I’m not sure about what you want to ask for your second part. Binding has generally a non negligible cost. What you need to do will depend on your VBOs. Are there data static or do you stream them constantly ?
glDrawArrays() uses a contiguous set of vertices. You can use an arbitrary set of vertices by using glDrawElements(). But if you want to change the set of vertices, you’d need to re-build the index array (which requires less work than changing the attribute arrays, but still more work than using glMultiDrawArrays() or glMultiDrawElements()).
Multiple draw commands are more expensive than a single draw command. Multiple draw commands with state changes between them are likely to be more expensive still. As to how much more expensive, you just have to measure it.