I've been reading a few (basic) tutorials about shaders. So far they've covered how to set variables in your shader. But this was only about ints, floats or vectors. I can't find anything about how to set a mat4 variable. My shader expects the following:
uniform vec3 CameraPos;
uniform mat4 ModelWorld4x4;
So the camera position and the world matrix of a model. I think i have the CameraPos right, but how on earth do i set the ModelWorld4x4 variable??
This is how i set the vector3
campos = glGetUniformLocation(shader.id(), "CameraPos");
glUniform3f(campos, 0.0f, 0.0f, 3.0f);
This is (one of the methods) how i tried to set the mat4
glGetFloatv(GL_MODELVIEW_MATRIX, modelworld);
modelw = glGetUniformLocation(shader.id(), "ModelWorld4x4");
glUniformMatrix4fv(g_modelworld4x4, modelworld); // Not working
I'm using the Assimp library to load a model, so currently the world matrix is stored in the aiMatrix4x4 struct.
// world matrix of the model
aiMatrix4x4 m = nd->mTransformation;
// Save in a global variable
g_modelworld4x4 = m;