Hi guys, I started moving one of my projects from a stationary pipeline, so to try everything, I tried to write a shader that would just pass OpenGL matrices and convert the vertex with that, and then start calculating my own as soon as I knew that it worked. I thought it would be a simple task, but even that would not work.
I started with this shader for a regular fixed pipeline:
void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; }
Then I changed it to the following:
uniform mat4 model_matrix; uniform mat4 projection_matrix; void main(void) { gl_Position = model_matrix * projection_matrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; }
Then, I extract OpenGL matrices like this and pass them to the shader using this code:
[material.shader bindShader]; GLfloat modelmat[16]; GLfloat projectionmat[16]; glGetFloatv(GL_MODELVIEW_MATRIX, modelmat); glGetFloatv(GL_PROJECTION_MATRIX, projectionmat); glUniformMatrix4fv([material.shader getUniformLocation:"model_matrix"], 1, GL_FALSE, modelmat); glUniformMatrix4fv([material.shader getUniformLocation:"projection_matrix"], 1, GL_FALSE, projectionmat ); ... Draw Stuff
For some reason, it doesnโt draw anything (Iโm 95% positive, these matrices are correct before passing them by the way) Any ideas?
source share