Hey everyone!
I’m currently playing around with glBindBufferBase. Let’s assume I have a uniform buffer of size 4 * 16 * sizeof(GLfloat), where one collection of uniforms has the size 1 * 16 * sizeof(GLfloat). Now I’m rendering 4 objects and I want to bind one collection at a time and use it within the active shader with the following block declaration:
layout(std140) uniform Collection
{
vec4 c0;
vec4 c1;
vec4 c2;
vec4 c3;
}
Since my driver reports an offset alignment of 256 machine units, I get an INVALID_VALUE error when binding buffer range like this:
glBindBufferRange(GL_UNIFORM_BUFFER, buffer_index, offset, 16 * sizeof(GLfloat));
with offset = i * 16 * sizeof(GLfloat) and i € {0, 1, 2, 3}.
Do I have to face facts and realize that I can only bind a collection which has a size equal to the offset alignment, or am I terribly missing somethin here?
Do I need to resort to indexing into an array of structs within the UB and use a constant size (which totally defeats the purpose), or go back to using glUniform*() which will result in a massive increase in API calls with more then just a few objects?
I’m using OpenGL 3.3 Core. Thank you!
Edit: BTW, gDEBugger confirmed that the buffer is setup correctly and so is the uniform block binding.