I have a program i created with a rotating sphere (glutWireSphere) and i like to change the rotation to the exact opposite direction.
For example if it rotates slowly CW on the Y axis i want it to rotate CCW.
Here is the code i have so far:
float angle = 0.;
void display() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glTranslatef(0., -1.5, 0.);
glRotatef(angle, 0.5, 1., 0.5);
glColor3d(0, 0, 1);
glutWireSphere(2, 25, 15);
glPopMatrix();
glutSwapBuffers();
glFlush();
}
void idle() {
angle += 0.2;
if (angle > 360.) angle -= 360.;
glutPostRedisplay();
}
void myinit() {
glClearColor(1.0, 1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-6., 6., -6., 6., -6., 6.);
glMatrixMode(GL_MODELVIEW);
}
void main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB);
glutInitWindowSize(400, 400);
glutInitWindowPosition(10, 10);
glutCreateWindow("3d objects");
glutDisplayFunc(display);
glutIdleFunc(idle);
glEnable(GL_DEPTH_TEST);
myinit();
glutMainLoop();
}
To do what i just wrote i changed the values of the X, Y & Z arguments inside the glRotatef function of the display function to -0.5,-1.,-0.5 and i still get the exact same rotation.
I also tried to change the idle function to this (with the original glRotatef arguments):
void idle() {
angle -= 0.2;
if (angle < 0.) angle += 360.;
glutPostRedisplay();
}
And still, same rotation.
Am i missing something in my understanding here about the glRotatef function?