void display(void) { glClear (GL_COLOR_BUFFER_BIT); glClear (GL_DEPTH_BUFFER_BIT); glPushMatrix(); glColor3f(1.0, 1.0, 0.0); if(shapeState == 0) glutSolidSphere(1.0, 20, 16); /* draw sun */ else if(shapeState == 1) glutWireSphere(1.0, 20, 16); glRotatef ((GLfloat) year, 0.0, 1.0, 0.0); glTranslatef (2.0, 0.0, 0.0); /* draw moon before rotating for earth exis spin */ glPushMatrix(); glRotatef((GLfloat) year, 0.0, 1.0, 0.0); glTranslatef(0.5, 0.0, 0.0); glRotatef((GLfloat) month, 0.0, 1.0, 0.0); //glTranslatef(2.0, 0.0, 0.0); glColor3f(1.0, 1.0, 1.0); if(shapeState == 0) glutSolidSphere(0.1, 10, 8); // Draw moon else if(shapeState == 1) glutWireSphere(0.1, 10, 8); glPopMatrix(); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glColor3f(0.0, 0.0, 1.0); if(shapeState == 0) glutSolidSphere(0.2, 10, 8); /* draw earth */ else if(shapeState == 1) glutWireSphere(0.2, 10, 8); glPopMatrix(); glutSwapBuffers(); }