When does it make sense to use drawRangeElements I am trying to understand when it makes sense to use the glDrawRangeElements function.

The OpenGL wiki says:


  for optimization purposes, it is useful for implementations to know the range of indexed rendering data


So, as I interpret it, if I had one large buffer (containing say, multiple meshes' data) and I was planning to call glDrawRangeElements if I instead specify the minimum and maximum index values that this call will use, I could achieve a speedup.

Is this a correct use case for glDrawRangeElements?

It seems like I would almost always know the minimum and maximum index values (because I would know ahead of time what I am going to draw) so it seems like glDrawRangeElements should be just a drop in replacement for glDrawElements.

However, this answer implies that glDrawRangeElements might actually be slower.

So, what are the pros and cons of using glDrawRangeElements?
The problem glDrawRangeElements was invented to fix was effectively removed by the advent of vertex buffers.

What glDrawRangeElements allows the implementation to do is to know exactly what range of values will be used as indices for the vertex arrays. Given that knowledge, they can read that range of values into a separate buffer, and then render from that buffer. Without knowing the range of indices, that wouldn't be possible, since an index list could pick from any index.

But that's only useful if you're reading from client memory. Copying that range out of client memory allows you to render asynchronously. You copy out the values you know you need, issue a rendering command with that, and then return to the caller.

If you're reading from buffer objects, this isn't a useful thing to do. And since core OpenGL doesn't even allow you the option of using client memory, the Range commands are no longer useful.