- 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();
-}