I have this shader code (GLSL):
#version 420
in vec4 vertex;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
void main()
{
gl_Position = modelViewMatrix * projectionMatrix * vertex;
}
If I don't set modelViewMatrix and projectionMatrix, it runs without error. If I do, OpenGL throws an Invalid Operation exception when I try to draw.
I set the matrices via this code:
glUniformMatrix4fv(location, 1, false, sendArray);
I have verified that "location" and "sendArray" contain the proper data. What's going on here?
EDIT: the problem appears to be in the glUniformMatrix4fv call, but I don't know what's wrong with it.
The code to set up location
is as follows:
GLint location;
GLint location = glGetUniformLocation(this->programID, uniform.c_str());
if (location == -1)
{
throw ShaderVariableNotFoundException(uniform, this->programID);
}
I fixed it, but I'm loathe to tell you all the solution because of how embarrassing it is...
I...
I forgot to bind the shader program.
I'm so sorry for wasting all of your time.
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