I am fairly new to graphics programming and I am trying to pass a custom Matrix4 (non-glm) to my vertex shader by using a uniform.
Matrix44 transform; //creates a 4x4 identity matrix
transform.SetTranslation(Vector3(0.5f, 0.3f, 0.0f));
GLint transformLocation = glGetUniformLocation(ourShader.Program, "transformation");
glUniformMatrix4fv(transformLocation, sizeof(transform), GL_FALSE, &transform.m[0][0]);
Above is the code which I am using to send the matrix to the shaders.
(the .m allows me to access the matrix as a 2D array of 4x4 floats);
This is how my vertex shader looks like:
#version 430 core
layout (location = 0) in vec3 position;
uniform mat4 transform;
void main()
{
gl_Position = transform*vec4(position,1.0f);
}
When I run it, I don't get anything drawn on my screen, except the background color.
Below is the matrix which I send to the shader. I am using column major, so as far as I've read this should be the translation part of the 4x4. I've also tried transposing the matrix with no luck whatsoever.
The last clue I have is that the values which I am sending are 0s. I came to this conclusion because I tried playing with the fragment shader and I set the color to be equal to the last column from the uniform mat4:
#version 430 core
out vec4 color;
uniform mat4 transform;
void main()
{
color = vec4(transform[0][3],transform[1][3], transform[2][3], transform[3][3]);
}
Which gives me a black triangle i.e. the color vec4 is filled with 0s.
I apologize in advance if the question is too noob-ish but I've been struggling with this for several days and I could not find a way to run it :(
Any advise would be appreciated!