I'm having an issue with interface block binding.
Example shader:
const char* vertexShader =
"#version 330 core\n"
"uniform globalMatrices"
"{"
" mat4 vPMatrix;"
"};"
"layout(location = 0) in vec2 vPosition;"
"layout(location = 1) in vec4 vColor;"
"out vec4 color;"
"void main()"
"{"
" color = vColor;"
" gl_Position = vPMatrix * vec4(vPosition, 1.0, 1.0);"
"}"
After creating the shader program i call functions:
//this is done once per shader
void BindShaderToMatrixBlock(unsigned int program)
{
GLuint globalUniformBlockIndex = glGetUniformBlockIndex(program, "globalMatrices");
glUniformBlockBinding(program, globalUniformBlockIndex, 0);
}
//this is done once
void BindUniformBlockMatrix()
{
glGenBuffers(1, &uniformBlockMatrix);
glBindBuffer(GL_UNIFORM_BUFFER, uniformBlockMatrix);
glBufferData(GL_UNIFORM_BUFFER, sizeof(glm::mat4), NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
glBindBufferRange(GL_UNIFORM_BUFFER, 0, uniformBlockMatrix, 0, sizeof(glm::mat4));
}
And this is how i update the matrix:
inline void SetVPMatrix(const void* data)
{
glBindBuffer(GL_UNIFORM_BUFFER, uniformBlockMatrix);
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(glm::mat4), data);
}
I tried to debug as much as i could and confirmed that the data gets delivered to the uniform block but for some reason the matrix in the shader stays unchanged.