I'm trying to pass my matrices to GLSL and having a tough time doing it. When using the built in (deprecated) gl_ModelViewProjectionMatrix etc it works, but when defining and sending my own into GLSL, nothing draws....
Here's my code (very simple):
vert shader:
uniform mat4 projectionMatrix;uniform mat4 modelViewMatrix;void main(){ //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_Position = projectionMatrix * modelViewMatrix * gl_Vertex;}
Here's my code snippets to send the information
//Projection MatrixGLfloat projectionMatrix[16];glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix);//Pass to shaderglUniformMatrix4fv(shader->projectionMatrix, 1, false, projectionMatrix);//MV matrixGLfloat modelViewMatrix[16];glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatrix);glUniformMatrix4fv(shader->modelViewMatrix, 1, false, modelViewMatrix);
I've debugged and checked that:
- the GLints of the uniforms are present. They are 0, 1;
- Both the projection and Modelview matrices are populating in the glGetFloatv command.
So...I'm just not sure why the above isn't working. When I switch back to using the built-in (deprecated) gl_ModelViewMatrix, etc. everything draws fine.
I'm a bit suspicious of the 'count' argument. I'm not sure if it should be 1 for 1 matrix or 16 for 16 values in the array. Both don't work in this case...
Any help would be most appreciated. Thanks,
Leonard