#include "graphics.h" //Function declarations
#include "nbody.h" //The simulation
+#include <GL/freeglut.h>
// --- Variable definitions --- //
double previousTime, eyeTheta, eyePhi, eyeRho;
*/
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;
}
{
if (theKey == 'x' || theKey == 'X')
{
- exit(EXIT_SUCCESS);
+ glutLeaveMainLoop();
+ return;
}
if (theKey == 'i' || theKey == 'I') {