3 * @author Sam Moore (20503628) 2012 - adapted from template program provided by UWA
7 * Initialization of graphics
11 glClearColor(1.0,1.0,1.0,0.0);
12 glColor3f(0.0f, 0.0f, 0.0f);
13 glPointSize(POINT_SIZE);
14 glMatrixMode(GL_PROJECTION);
19 GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
20 GLfloat mat_shininess[] = { 50.0 };
21 GLfloat light_position[] = { 1.0, 1.0, 0.0, 0.0 };
22 glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
23 glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
24 glLightfv(GL_LIGHT0, GL_POSITION, light_position);
26 glColorMaterial(GL_FRONT,GL_DIFFUSE); // Set Color Capability
28 glEnable(GL_LIGHTING);
30 glEnable(GL_DEPTH_TEST);
32 glEnable(GL_COLOR_MATERIAL); // Enable color
34 double displayRatio = 1.0 * WIDTH / HEIGHT;
36 windowHeight = HEIGHT;
37 previousTime = clock();
45 gluPerspective(VIEW_ANGLE, displayRatio, WORLD_NEAR, WORLD_FAR);
49 * This function redraws the screen after the positions of particles
53 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
54 glMatrixMode(GL_MODELVIEW);
56 gluLookAt(eyeRho * sin(eyePhi) * sin(eyeTheta), eyeRho * cos(eyePhi),
57 eyeRho * sin(eyePhi) * cos(eyeTheta),
58 look[0], look[1], look[2], 0, upY, 0);
60 for (int i = 0; i < N; i++) {
61 //glClearColor(1.0,1.0,1.0,0.0);
62 glColor3f(0.0f, body[i].mass/1e11*100, 0.0f);
63 //glColor3f(1.0f, 0.0f, 0.0f);
64 glPushMatrix(); // to save the current matrix
65 glTranslated(SCALE*body[i].X, SCALE*body[i].Y, SCALE*body[i].Z);
66 glutSolidSphere (BALL_SIZE, 10, 10);
67 glPopMatrix(); // restore the previous matrix