+/**
+ * @file graphics.c
+ * @author Sam Moore (20503628) 2012 - adapted from template program provided by UWA
+ * @pur
+
+/*
+ * Initialization of graphics
+ */
+void Init(void) {
+
+ glClearColor(1.0,1.0,1.0,0.0);
+ glColor3f(0.0f, 0.0f, 0.0f);
+ glPointSize(POINT_SIZE);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ /*init lighting */
+
+ GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
+ GLfloat mat_shininess[] = { 50.0 };
+ GLfloat light_position[] = { 1.0, 1.0, 0.0, 0.0 };
+ glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+ glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+
+ glColorMaterial(GL_FRONT,GL_DIFFUSE); // Set Color Capability
+
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_DEPTH_TEST);
+
+ glEnable(GL_COLOR_MATERIAL); // Enable color
+
+ double displayRatio = 1.0 * WIDTH / HEIGHT;
+ windowWidth = WIDTH;
+ windowHeight = HEIGHT;
+ previousTime = clock();
+ eyeTheta = 0;
+ eyePhi = 0.5 * M_PI;
+ eyeRho = RHO;
+ upY = 1;
+ look[0] = 0;
+ look[1] = 0;
+ look[2] = 0;
+ gluPerspective(VIEW_ANGLE, displayRatio, WORLD_NEAR, WORLD_FAR);
+}
+
+/*
+ * This function redraws the screen after the positions of particles
+ * have been updated
+ */
+void Display(void) {
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ gluLookAt(eyeRho * sin(eyePhi) * sin(eyeTheta), eyeRho * cos(eyePhi),
+ eyeRho * sin(eyePhi) * cos(eyeTheta),
+ look[0], look[1], look[2], 0, upY, 0);
+
+ for (int i = 0; i < N; i++) {
+ //glClearColor(1.0,1.0,1.0,0.0);
+ glColor3f(0.0f, body[i].mass/1e11*100, 0.0f);
+ //glColor3f(1.0f, 0.0f, 0.0f);
+ glPushMatrix(); // to save the current matrix
+ glTranslated(SCALE*body[i].X, SCALE*body[i].Y, SCALE*body[i].Z);
+ glutSolidSphere (BALL_SIZE, 10, 10);
+ glPopMatrix(); // restore the previous matrix
+ }
+ glFlush();
+}