In OpenGL ES 2.0, you apparently can't do
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
any more to set the model matrix, but I think these matrices are still built in somehow, since the GLSL spec tells you how to access them in a vertex shader.
//
// Matrix state. p. 31, 32, 37, 39, 40.
//
uniform mat4 gl_ModelViewMatrix;
uniform mat4 gl_ProjectionMatrix;
uniform mat4 gl_ModelViewProjectionMatrix;
so how do I pass these values to my shader? do I use glUniformMatrix4fv
somehow?
The source code from the OpenGL ES 2.0 Programming Guide has been helpful for the shader part but all the examples appear to just leave the matrix transforms alone and just make sure their vertices are between -1.0 and 1.0.
UPDATE: apparently the OpenGL ES Shader Language does not support the pre-defined entries like gl_ModelViewMatrix
, so the only answer is to define your own custom model/view/projection matrices as done in the code linked below, using glGetUniformLocation
and glUniformMatrix4fv
. I was confused because the OpenGL Shader Builder does support them, but that's plain OpenGL, not OpenGL ES.