I think what glBindBuffer(target, buffer)
do is to store the buffer's address on the target, which is a special address.
But I found the glBindBufferBase(target, index, buffer)
. I think target should be a array, this operation stores the buffer address to the array according to the index.
If what I thought is right, then the glBindBuffer
is equivalent to glBindBufferBase(target, someindex, buffer)
?
Maybe someindex
is 0?
They're not used for the same purpose.
glBindBuffer
is used to bind a buffer to a specific target so that all operations which modify that target are mapped to that buffer afterwards.
glBindBufferBase
is used for a totally different purpose, it's used bind a buffer to a specific binding point in an indexed array (when data is not supposed to be directly modified but rather used). While this may seem convoluted it's really easy to see. Assume you want to pass an uniform block to your shader, then you have a table which maps named buffers to specific indices in an array which are then mapped to bindings in a shader like in the following figure:
so glBindBufferBase
is creating the arrows on the right in which you specify the index, while glBindBuffer
is just binding the buffer to the specific target.
You would then use glGetUniformBlockIndex
to get the correct index in the shader which is then linked to the binding point (the left arrows) through glUniformBlockBinding
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With