PUSH AND POP OF MODELVIEW MATRIX glPushMatrix(); /* save start matrix */ glPushMatrix(); /* save start matrix again */ glRotatef ((GLfloat) year, 0.0, 1.0, -1.0); /* rotate sun */ glutWireSphere(1.0, 20, 16); /* draw sun */ glPopMatrix(); /* get start matrix, forget about sun */ glRotatef ((GLfloat) year, -1.0, 2.0, 0.0); /* rotate planet+moon */ glTranslatef (2.0, 1.0, 0.0); /* translate from sun center */ glPushMatrix(); /* save position of planet+moon */ glRotatef ((GLfloat) day, -0.3, 1.0, 0.0); /* rotate planet */ glutWireSphere(0.2, 10, 10); /* draw planet */ glPopMatrix(); /* get position of planet+moon */ glRotatef ((GLfloat) day, 0.0, 0.0, 1.0); /* rotate moon itself */ glTranslatef (0.0, 1.0, 0.0); /* translate from planet center */ glRotatef ((GLfloat) day*3, 0.0, 0.0, 1.0); /* rotate around planet */ glutWireSphere(0.1, 10, 10); /* draw moon */ glPopMatrix(); /* get start matrix, forget previous */