OpenGL ES 2.0 how to implement matrix transforms in OpenGL such as glLoadIdentity
Dear everyone:
For my OpenGL ES 2.0 program requiring to achieve some necessary matrices that supported by OpenGL such as glLoadIdentity, glLoadMatrix, glMultMatrix, glTranslate, glRotate, glFrustum, gluPerspective, gluOrtho2D, inverse of coordinate transforms, .etc.
But as we known, in <OpenGL ES 2.0 Commom Specification> has specified that "The fixed function transformation pipeline is no longer supported. The application can compute the necessary matrices (can be the combined modelview and projection matrix, or an array of matrices for skinning) and load them as uniform variables in the vertex shader."
You may doubt that why I should implement these functions for OpenGL ES 2.0 vertex shader can do this for me, but sometimes my application need to use these matrices.
So I want to know how can I realize it, I don't want to do by the help of EGL,.etc. What I want to realize just somehow likewise EGL.
and I have write a brief code to realize matric-----glLoadIdentity, and I then want to use an OpenGL program to test wether my code was right or not.
Here is my brief code to realize glLoadIdentity.
Code:
typedef struct
{
GLfloat m[4][4];
}A3Matrix;
extern void mat_LoadIdentity(A3Matrix *result)
{
memset(result, 0x0, sizeof(A3Matrix));
result->m[0][0] = 1.0f;
result->m[1][1] = 1.0f;
result->m[2][2] = 1.0f;
result->m[3][3] = 1.0f;
}
and here is part of my code to use my code above in an actual OpenGL example.
Code:
void display(void)
{
/* display callback, clear frame buffer and z buffer,
rotate cube and draw, swap buffers */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glLoadIdentity();
mat_LoadIdentity(???); //here I use my code,but I don't know what is the current martix
glRotatef(theta[0], 1.0, 0.0, 0.0);
glRotatef(theta[1], 0.0, 1.0, 0.0);
glRotatef(theta[2], 0.0, 0.0, 1.0);
colorcube();
glutSwapBuffers();
}
as the question produces above by calling my function mat_LoadIdentity(), because I don't know how can I get the current matric.
I run on the open source of OpenGL code-----mesa3D
I do really wish who can tell me? maybe my thought above was wrong, wish you can give directions to me on how to implement matrix transforms in OpenGL such as glLoadIdentity , do not use any API that OpenGL ES doesn't support .
Thank you very very very very much.
Wait for your answer soon ! Thank you again loyally !