void idle(void) { if(reality_mode) { static long oldtime = 0; long newtime = get_time(); long dt = newtime - oldtime; oldtime = newtime; elevation += (double)dt*MULTIPLIER*ELEV_RATE* (int)((double)(mousey - ae_window_width()/2)/5); while(elevation > M_PI_2) { elevation -= M_PI; azimuth -= 2*M_PI; } while(elevation < -M_PI_2) { elevation += M_PI; azimuth += 2*M_PI; } azimuth += (double)dt*MULTIPLIER*AZI_RATE* (int)((double)(mousex - ae_window_width()/2)/5); while(azimuth > M_PI) azimuth -= 2.0*M_PI; while(azimuth < -M_PI) azimuth += 2.0*M_PI; if(action & ROLL) { roll += (double)dt*MULTIPLIER*ROLL_RATE* (int)((double)(mousex - ae_window_width()/2)/5); while (roll > 2.0*M_PI) roll = roll - 4.0*M_PI; if (compass_win_exists) { glutSetWindow(compass_win); glutPostRedisplay(); glutSetWindow(disp_win); } } glutSetWindow(ae_win); glutPostRedisplay(); glutSetWindow(disp_win); recalc_view_and_up_from_AER(); really_look_at_it(); } else { if (action & ROLL) { roll_clockwise(); if (compass_win_exists) { glutSetWindow(compass_win); glutPostRedisplay(); glutSetWindow(disp_win); } } } if (action & ZOOM_IN) zoom(); else if (action & ZOOM_OUT) zoom(); if (action & SPIN) do_spin(); glutSetWindow(disp_win); glutPostRedisplay(); }
void scene_redraw(void) { really_look_at_it(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); /* Draw cube 1 */ glScalef(1.0, 1.0, 1.0); glTranslatef(-5.0, 0.0, -10.0); glRotatef(spin, 0.0, -1.0, 0.0); cube_material(); objSolidCube(); /* Draw cube 2 */ glLoadIdentity(); glScalef(0.2, 0.2, 0.2); glTranslatef(-5.0, 0.5, -10.0); glRotatef(spin, -0.5, 1.0, 0.0); teapot_material(); objSolidCube(); /* Draw ground */ glLoadIdentity(); glScalef(200.0/(GLfloat)GW, 4.0, 200.0/(GLfloat)GH); /* 2000.0 yeilds a semi-infinite ground */ glRotatef(90.0, 1.0, 0.0, 0.0); glTranslatef((GLfloat)-GW/2.0, (GLfloat)-GH/2.0, 5.0); draw_ground(); /* Draw icosahedron */ glLoadIdentity(); glTranslatef(0.0, 0.0, -50.0); glRotatef(spin*3, 1.0, 1.0, 0.0); icosahedron_material(); objSolidIcosahedron(); /* Draw tardis */ glLoadIdentity(); glTranslatef(0.1, 0.0, -2.0); objTardis(); /* Draw Stars */ glLoadIdentity(); glDisable(GL_LIGHTING); glColor3f(1.0, 1.0, 1.0); objStars(); glEnable(GL_LIGHTING); glPopMatrix(); /* glFlush();*/ }