Parallel Programming - Start OpenMP Version
[matches/honours.git] / course / semester2 / pprog / assignment1 / single-thread / graphics.c
index e3722e9..1b4fcb3 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "graphics.h" //Function declarations
 #include "nbody.h" //The simulation
+#include <GL/freeglut.h>
 
 // --- Variable definitions --- //
 double previousTime, eyeTheta, eyePhi, eyeRho;
@@ -106,37 +107,34 @@ void Graphics_Run(int argc, char ** argv)
  */
 void Graphics_Display() 
 {
+       //Check whether the program should quit due to steps being computed, or a timeout
+       if (ExitCondition())
+       {
+               glutLeaveMainLoop();
+               return;
+       }
 
 
-       if (options.verbosity != 0 && universe.steps % options.verbosity == 1)
-               DisplayStatistics();
-
        #ifdef SINGLE_THREADED
+               if (options.verbosity != 0 && universe.steps % options.verbosity == 1)
+                       DisplayStatistics();
                System_Compute(&universe);
-
-               //Check whether the program should quit due to steps being computed, or a timeout
-               if (options.timeout > 0.0)
-               {
-                       if ((unsigned)(time(NULL) - options.start_time.tv_sec) >= options.timeout)
-                               exit(EXIT_SUCCESS);
-               }
-               if (options.num_steps > 0 && universe.steps > options.num_steps)
-                       exit(EXIT_SUCCESS);
-
-
        #endif
 
 
+
        //Check whether the runstate has been set to quit the program
        switch (runstate)
        {
                case RUN:
                        break;
                case QUIT:
-                       exit(EXIT_SUCCESS);
+                       glutLeaveMainLoop();
+                       return;
                        break;
                case QUIT_ERROR:
-                       exit(EXIT_FAILURE);
+                       glutLeaveMainLoop();
+                       return;
                        break;
        }
 
@@ -172,7 +170,8 @@ void Graphics_Keyboard(unsigned char theKey, int mouseX, int mouseY)
 {
        if (theKey == 'x' || theKey == 'X') 
        {
-               exit(EXIT_SUCCESS);
+               glutLeaveMainLoop();
+               return;
        }
 
                if (theKey == 'i' || theKey == 'I') {

UCC git Repository :: git.ucc.asn.au