When using UBOs, we bind a uniform block to a binding point. Then we also bind the UBO to the same binding point: something like:
glUseProgram(ProgramName);
glUniformBlockBinding(ProgramName, uniformLocation, bindingPoint);
glBindBufferBase(GL_UNIFORM_BUFFER, bindingPoint, bufId);
I have 2 questions on this:
glUniformBlockBinding
sets state in the program (which is why you shouldn't be calling it every frame). glBindBufferRange
sets state in the OpenGL context. Neither affects the other until you render, so no, it doesn't matter which.
And yes, you cannot call glBindBufferRange
(or Base, which is defined in terms of Range) unless you have allocated storage for the buffer object.
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