+
+/**
+ * This function is to manipulate with the image
+ */
+void Graphics_Keyboard(unsigned char theKey, int mouseX, int mouseY)
+{
+ if (theKey == 'x' || theKey == 'X')
+ {
+ exit(EXIT_SUCCESS);
+ }
+
+ if (theKey == 'i' || theKey == 'I') {
+ eyePhi -= M_PI / 20;
+ if (eyePhi == 0)
+ eyePhi = 2 * M_PI;
+ } else if (theKey == 'm' || theKey == 'I') {
+ eyePhi += M_PI / 20;
+ } else if (theKey == 'j' || theKey == 'J') {
+ eyeTheta -= M_PI / 20;
+ } else if (theKey == 'k' || theKey == 'K') {
+ eyeTheta += M_PI / 20;
+ } else if (theKey == ',') {
+ eyeRho += 0.5;
+ } else if (theKey == '.' || theKey == 'I') {
+ eyeRho -= 0.5;
+ } else if (theKey == 'w' || theKey == 'W') {
+ look[1] += 0.5;
+ } else if (theKey == 'z' || theKey == 'Z') {
+ look[1] -= 0.5;
+ } else if (theKey == 'a' || theKey == 'A') {
+ look[0] -= 0.5;
+ } else if (theKey == 's' || theKey == 'S') {
+ look[0] += 0.5;
+ } else if (theKey == '+') {
+ scale *= 1.1;
+ } else if (theKey == '-') {
+ scale *= 0.9;
+ }
+ if (sin(eyePhi) > 0) upY = 1;
+ else upY = 1;
+}
+
+/**
+ * Resize the view window
+ */
+void Graphics_Reshape(int width, int height)
+{
+ double displayRatio = 1.0 * width / height;
+ windowWidth = width;
+ windowHeight = height;
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(VIEW_ANGLE, displayRatio, WORLD_NEAR, WORLD_FAR);
+ glViewport(0, 0, windowWidth, windowHeight);
+}
+
+
+/**
+ * This function is called repeatedly by graphics library. You can consider
+ * it as main loop in the program.
+ */
+void Graphics_Animate(void)
+{
+
+ System_Compute(&universe); //Compute and update new positions for the time step
+ Graphics_Display(&universe); // Display needs to be called to redraw the screen
+}