// commented out to remove unused parameter warnings in Linux void key(unsigned char key, int /*x*/, int /*y*/) { switch (key) { case ' ': bPause = !bPause; break; case '\033': case 'q': exit(0); break; case '`': bShowSliders = !bShowSliders; break; case 'p': displayMode = (ParticleRenderer::DisplayMode) ((displayMode + 1) % ParticleRenderer::PARTICLE_NUM_MODES); break; case 'c': cycleDemo = !cycleDemo; printf("Cycle Demo Parameters: %s\n", cycleDemo ? "ON" : "OFF"); break; case '[': activeDemo = (activeDemo == 0) ? numDemos - 1 : (activeDemo - 1) % numDemos; selectDemo(activeDemo); break; case ']': activeDemo = (activeDemo + 1) % numDemos; selectDemo(activeDemo); break; case 'd': displayEnabled = !displayEnabled; break; case 'O': activeParams.print(); break; case '1': reset(nbody, numBodies, NBODY_CONFIG_SHELL); break; case '2': reset(nbody, numBodies, NBODY_CONFIG_RANDOM); break; case '3': reset(nbody, numBodies, NBODY_CONFIG_EXPAND); break; } glutPostRedisplay(); }
// commented out to remove unused parameter warnings in Linux void key(unsigned char key, int /*x*/, int /*y*/) { switch (key) { case ' ': bPause = !bPause; break; case 27: // escape case 'q': case 'Q': cudaDeviceReset(); exit(EXIT_SUCCESS); break; case 13: // return if (bSupportDouble) { if (fp64) { switchDemoPrecision<float, double>(); } else { switchDemoPrecision<double, float>(); } printf("> %s precision floating point simulation\n", fp64 ? "Double" : "Single"); } break; case '`': bShowSliders = !bShowSliders; break; case 'g': case 'G': bDispInteractions = !bDispInteractions; break; case 'p': case 'P': displayMode = (ParticleRenderer::DisplayMode) ((displayMode + 1) % ParticleRenderer::PARTICLE_NUM_MODES); break; case 'c': case 'C': cycleDemo = !cycleDemo; printf("Cycle Demo Parameters: %s\n", cycleDemo ? "ON" : "OFF"); break; case '[': activeDemo = (activeDemo == 0) ? numDemos - 1 : (activeDemo - 1) % numDemos; selectDemo(activeDemo); break; case ']': activeDemo = (activeDemo + 1) % numDemos; selectDemo(activeDemo); break; case 'd': case 'D': displayEnabled = !displayEnabled; break; case 'o': case 'O': activeParams.print(); break; case '1': if (fp64) { NBodyDemo<double>::reset(numBodies, NBODY_CONFIG_SHELL); } else { NBodyDemo<float>::reset(numBodies, NBODY_CONFIG_SHELL); } break; case '2': if (fp64) { NBodyDemo<double>::reset(numBodies, NBODY_CONFIG_RANDOM); } else { NBodyDemo<float>::reset(numBodies, NBODY_CONFIG_RANDOM); } break; case '3': if (fp64) { NBodyDemo<double>::reset(numBodies, NBODY_CONFIG_EXPAND); } else { NBodyDemo<float>::reset(numBodies, NBODY_CONFIG_EXPAND); } break; } glutPostRedisplay(); }
// GLUT key event handler //***************************************************************************** void KeyboardGL(unsigned char key, int /*x*/, int /*y*/) { switch (key) { case ' ': // space toggle computation flag on/off bPause = !bPause; shrLog("\nSim %s...\n\n", bPause ? "Paused" : "Running"); break; case 's': case 'S': // Tilda toggles slider display bShowSliders = !bShowSliders; shrLog("\nSlider Display %s...\n\n", bShowSliders ? "ON" : "OFF"); break; case 'p': // 'p' falls through to 'P' case 'P': // p switched between points and blobs displayMode = (ParticleRenderer::DisplayMode)((displayMode + 1) % ParticleRenderer::PARTICLE_NUM_MODES); break; case 'c': // 'c' falls through to 'C' case 'C': // c switches between cycle demo mode and fixed demo mode bTour = bTour ? shrFALSE : shrTRUE; shrLog("\nTour Mode %s...\n\n", bTour ? "ON" : "OFF"); break; case '[': activeDemo = (activeDemo == 0) ? numDemos - 1 : (activeDemo - 1) % numDemos; SelectDemo(activeDemo); break; case ']': activeDemo = (activeDemo + 1) % numDemos; SelectDemo(activeDemo); break; case 'd': // 'd' falls through to 'D' case 'D': // d toggled main graphics display on/off displayEnabled = !displayEnabled; shrLog("\nMain Graphics Display %s...\n\n", displayEnabled ? "ON" : "OFF"); break; case 'f': // 'f' falls through to 'F' case 'F': // f toggles main graphics display full screen bFullScreen = !bFullScreen; if (bFullScreen) { iGraphicsWinPosX = glutGet(GLUT_WINDOW_X) - 8; iGraphicsWinPosY = glutGet(GLUT_WINDOW_Y) - 30; iGraphicsWinWidth = min(glutGet(GLUT_WINDOW_WIDTH) , glutGet(GLUT_SCREEN_WIDTH) - 2*iGraphicsWinPosX ); iGraphicsWinHeight = min(glutGet(GLUT_WINDOW_HEIGHT), glutGet(GLUT_SCREEN_HEIGHT)- 2*iGraphicsWinPosY ); printf("(x,y)=(%d,%d), (w,h)=(%d,%d)\n", iGraphicsWinPosX, iGraphicsWinPosY, iGraphicsWinWidth, iGraphicsWinHeight); glutFullScreen(); } else { glutPositionWindow(iGraphicsWinPosX, iGraphicsWinPosY); glutReshapeWindow(iGraphicsWinWidth, iGraphicsWinHeight); } shrLog("\nMain Graphics %s...\n\n", bFullScreen ? "FullScreen" : "Windowed"); break; case 'o': // 'o' falls through to 'O' case 'O': // 'O' prints Nbody sim physical parameters activeParams.print(); break; case 'T': // Toggles from (T)our mode to standard mode and back case 't': // Toggles from (t)our mode to standard mode and back bTour = bTour ? shrFALSE : shrTRUE; shrLog("\nTour Mode %s...\n", bTour ? "ON" : "OFF"); break; case '1': ResetSim(nbody, numBodies, NBODY_CONFIG_SHELL, true); break; case '2': ResetSim(nbody, numBodies, NBODY_CONFIG_RANDOM, true); break; case '3': ResetSim(nbody, numBodies, NBODY_CONFIG_EXPAND, true); break; case '\033': // escape quits case '\015': // Enter quits case 'Q': // Q quits case 'q': // q (or escape) quits // Cleanup and quit bNoPrompt = shrTRUE; shrQAFinish2(false, *pArgc, (const char **)pArgv, QA_PASSED); Cleanup(EXIT_SUCCESS); break; } // Trigger fps update and call for refresh TriggerFPSUpdate(); glutPostRedisplay(); }