//I have something like this
void positionCamera()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1.3333, 0.1, 50);
glTranslatef(tx, ty, tz);
glRotatef(rx, 1, 0, 0);
glRotatef(ry, 0, 1, 0);
}
//with tx, ty, tz, rx and ry are global
//variables which I increment them to rotate
//and position the ‘camera’ but the problem
//is the glRotatef(ry, 0, 1, 0);
//the y rotation point is at the origin???
//not the center of the ‘camera’
//And I don’t want to use gluLookAt
Should be:
void positionCamera()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1.3333, 0.1, 50);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(rx, 1, 0, 0);
glRotatef(ry, 0, 1, 0);
// translate first, then rotate
glTranslatef(tx, ty, tz);
}
(I think )
G.
Tried it before(both matrix mode and transformation order) but then the translation will have problems.