Hi everyone
First, I need to say that I just searched but my problem still stood still !
I wrote my own transformation and rotation functions and I called them elRotateX() for example for rotating around X,y,z axis.
void elRotateX()
{
GLfloat mat[] = {
1, 0, 0, 0, // X Column
0, cos(xRot), -sin(xRot), 0, // Y Column
0, sin(xRot), cos(xRot), 0, // Z Column
0, 0, 0, 1 // Trans
};
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(mat);
}
I also wrote my own
void elLoadIdentity()
{
GLfloat mat[] = {
1, 0, 0, 0, // X Column
0, 1, 0, 0, // Y Column
0, 0, 1, 0, // Z Column
0, 0, 0, 1 // Trans
};
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(mat);
}
and this is the imporatant part of my resize function:
glMatrixMode( GL_PROJECTION );
elLoadIdentity();
gluPerspective(25,(float)w/(float)h,1,200);
glMatrixMode(GL_MODELVIEW);
elLoadIdentity();
My rotation variables (xRot, yRot, zRot) are increased or decreased by Arrow keys.
When I use elRotate functions as above just rotates around Z axis. I pushed and popped matrixes and I replaced GL_MODELVIEWs
with GL_PROJECTION but I can’t rotate all three axises together.(for example x,y rotates but z doesn’t)
I read some Matrix concepts and I found out MODELVIEW you need to move whole scene with the inverse transformation.
but i didn’t get what exactly Projection does.
In my case how can I rotate all three axises?