Search code examples
c++openglmatrixglm-mathuniform

glUniformLocation returns -1


I'm trying to uniform a model matrix into a vertex shader using

glUniformMatrix4fv(glGetAttribLocation(shaderProgram, "modelMatrix"),
    1, GL_FALSE, glm::value_ptr(objmesh[0]->modelMatrix));

but when I use this, the model does not show. I've used

int location = glGetAttribLocation(shaderProgram, "modelMatrix");

to find the location but it only returns -1. I've also tried using a manually made matrix (as an identity matrix) in the vertex shader and when I do that it works. I've done this exact thing to another shader, just a different program.

objmesh is just a std::vector that contains a struct with a mesh's vertices, uvs and so fourth. As of now, the modelMatrix is just an identity matrix.

I uniform the matrix in the vertex shader like so: uniform mat4 modelMatrix;


Solution

  • Solved it: I accidentally used glGetAttribLocation instead of glGetUniformLocation