glDrawElements with indeces in GL buffer object?

Anybody know if there is a version of glDrawElements that takes the indices as a GL buffer object instead of a ptr to host memory?

I’m assuming the performance would be better if this index data could be kept on the GPU instead of copied from host memory each frame (?)

I’m on Mac 10.6 so I guess that means GL 2.1…

Thanks!

Standard glDrawElements does it, and it works just the same as gl*Pointer functions. You need to bind a buffer as GL_ELEMENT_ARRAY_BUFFER, then pass the offset (in bytes) as the last param of glDrawElements.

Doing this you’re going to be subjected to the messy details of the hardware, so don’t use GL_UNSIGNED_BYTE indexes, be aware of the max vertex index your hardware supports and whether or not you have hardware support for 32-bit indexes, otherwise you’ll probably fall back to software emulation and get no benefit from it.

Nice, thanks! That works!