#include "graphics.h" //Function declarations
#include "nbody.h" //The simulation
+#include <GL/freeglut.h>
// --- Variable definitions --- //
double previousTime, eyeTheta, eyePhi, eyeRho;
*/
void Graphics_Display()
{
-
-
- if (options.verbosity != 0 && universe.steps % options.verbosity == 1)
- DisplayStatistics();
+ //Check whether the program should quit due to steps being computed, or a timeout
+ if (ExitCondition())
+ {
+ //printf("Leave graphics loop\n");
+ glutLeaveMainLoop();
+ return;
+ }
#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);
- break;
- case QUIT_ERROR:
- exit(EXIT_FAILURE);
- break;
- }
-
if (options.draw_graphics == false)
return;
{
if (theKey == 'x' || theKey == 'X')
{
- exit(EXIT_SUCCESS);
+ QuitProgram(false);
+ return;
}
if (theKey == 'i' || theKey == 'I') {