*/
void Graphics_Run(int argc, char ** argv)
{
+
if (options.draw_graphics == false)
{
// This message is left here for when I inevitably accidentally call the function
glutCreateWindow("N-Body : Multi-Threaded (pthread)");
#elif defined OMP_THREADED
glutCreateWindow("N-Body : Multi-Threaded (OpenMP)");
+ #elif defined BARNES_HUT
+ glutCreateWindow("N-Body : Barnes Hut Algorithm");
#else
glutCreateWindow("N-Body");
#endif
#ifndef OMP_THREADED
- glutMainLoop();
+ #ifndef BARNES_HUT
+ glutMainLoop(); // the mthread and single-thread versions can just start the loop here
+ // In OpenMP, because barriers have to be within the #pragma, need glutMainLoopEvent in the #pragma
+ #endif //BARNS_HUT
#endif //OMP_THREADED
}
//Check whether the graphics thread should exit for any reason
if (ExitCondition())
{
+ QuitProgram(false);
glutLeaveMainLoop(); // original glut does not have this, which makes "nicely" exiting a bit annoying
return;
}
glutSolidSphere (BALL_SIZE, 10, 10);
glPopMatrix(); // restore the previous matrix
}
- glFlush();
+
AfterDraw(); // Stuff to do after graphics is done drawing
// Single-thread - Nothing at all
// Multiple threads - signal threads it is safe to change position variables
-
+ glFlush();
}
/**
}
#ifdef FLYING_CAMERA
+ float s = 10;
switch (theKey)
{
// Translate in direction of camera
case 'W':
case 'w':
for (unsigned i = 0; i < DIMENSIONS; ++i)
- eye.p[i] += eye.x[i];
+ eye.p[i] += s * eye.x[i];
break;
// Translate backwards from camera direction
case 'S':
case 's':
for (unsigned i = 0; i < DIMENSIONS; ++i)
- eye.p[i] -= eye.x[i];
+ eye.p[i] -= s * eye.x[i];
break;
// Translate left from camera direction
case 'A':
case 'a':
for (unsigned i = 0; i < DIMENSIONS; ++i)
- eye.p[i] -= eye.y[i];
+ eye.p[i] -= s * eye.y[i];
break;
// Translate right from camera direction
case 'D':
case 'd':
for (unsigned i = 0; i < DIMENSIONS; ++i)
- eye.p[i] += eye.y[i];
+ eye.p[i] += s * eye.y[i];
break;
// Translate up from camera direction
case 'Q':
case 'q':
for (unsigned i = 0; i < DIMENSIONS; ++i)
- eye.p[i] += eye.z[i];
+ eye.p[i] += s * eye.z[i];
break;
// Translate down from camera direction
case 'E':
case 'e':
for (unsigned i = 0; i < DIMENSIONS; ++i)
- eye.p[i] -= eye.z[i];
+ eye.p[i] -= s * eye.z[i];
break;
// Rotate camera direction "down"