static void key(unsigned char key, int x, int y) { char *s,str[2]; int win = glutGetWindow(); switch (key) { case 27 : case 'Q': case 'q': glutLeaveMainLoop () ; break; default: s=strings[win]; if (strlen(s)+1>MAXSTR) { s[0]=0; } str[0]=key; str[1]=0; strcat(s,str); break; } glutPostRedisplay(); }
//Called whenever a key on the keyboard was pressed. //The key is given by the ''key'' parameter, which is in ASCII. //It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to //exit the program. void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: delete g_pPlaneMesh; delete g_pCylinderMesh; glutLeaveMainLoop(); return; case 32: g_bScaleCyl = !g_bScaleCyl; break; case 't': case 'T': g_bDoInvTranspose = !g_bDoInvTranspose; if(g_bDoInvTranspose) printf("Doing Inverse Transpose.\n"); else printf("Bad lighting.\n"); break; } glutPostRedisplay(); }
void onKeyPressed(unsigned char key, int x, int y) { ::key = toupper(key); switch (::key) { case ESCAPE: glutLeaveMainLoop(); break; case RESET_CAMERA: ResetCamera(); break; case PAUSE: isPause = !isPause; break; case ROTATE_X: isRotateX = !isRotateX; break; case ROTATE_Y: isRotateY = !isRotateY; break; case RESTART: InitWell(); break; } }
//Called whenever a key on the keyboard was pressed. //The key is given by the ''key'' parameter, which is in ASCII. //It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to //exit the program. void keyboard(unsigned char key, int x, int y) { x = x; y = y; switch(key) { case 27: glutLeaveMainLoop(); return; case 'w': perspectiveMatrix[0] -= 0.1f; perspectiveMatrix[5] -= 0.1f; return; case 's': perspectiveMatrix[0] += 0.1f; perspectiveMatrix[5] += 0.1f; return; case 'q': fzNear -= 0.1f; return; case 'a': fzNear += 0.1f; return; case 'e': fzFar -= 0.1f; return; case 'd': fzFar += 0.1f; return; } }
static void display(void) { const struct piglit_gl_test_config *test_config = glut_fw.gl_fw.test_config; TRY if (test_config->display) glut_fw.result = test_config->display(); CATCH_ALL if (piglit_automatic) { glutDestroyWindow(glut_fw.window); #ifdef FREEGLUT /* Tell GLUT to clean up and exit, so that we can * reasonably valgrind our testcases for memory * leaks by the GL. */ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); glutLeaveMainLoop(); #else piglit_report_result(glut_fw.result); #endif } }
static void KeyboardCB(unsigned char Key, int x, int y) { switch (Key) { case 'q': glutLeaveMainLoop(); } }
//Called whenever a key on the keyboard was pressed. //The key is given by the ''key'' parameter, which is in ASCII. //It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to //exit the program. void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: delete g_pPlaneMesh; delete g_pCylinderMesh; glutLeaveMainLoop(); return; case 32: g_bDrawColoredCyl = !g_bDrawColoredCyl; break; case 't': case 'T': g_bShowAmbient = !g_bShowAmbient; if(g_bShowAmbient) printf("Ambient Lighting On.\n"); else printf("Ambient Lighting Off.\n"); break; } glutPostRedisplay(); }
//functia aceasta o apelati cand doriti sa inchideti glut void close() { if(!_initialized) return; _initialized=false; std::cout<<"GLUT:\tTerminat"<<std::endl; glutLeaveMainLoop(); }
virtual void keyboardCB(OGLDEV_KEY ogldevKey, OGLDEV_KEY_STATE ogldevKeyState = OGLDEV_KEY_STATE_PRESS) override { switch (ogldevKey) { //case OGLDEV_KEY_ESCAPE: case OGLDEV_KEY_Q: case OGLDEV_KEY_q: glutLeaveMainLoop(); break; case OGLDEV_KEY_A: case OGLDEV_KEY_a: m_directionalLight.ambientIntensity += 0.05f; break; case OGLDEV_KEY_S: case OGLDEV_KEY_s: m_directionalLight.ambientIntensity -= 0.05f; break; case OGLDEV_KEY_Z: case OGLDEV_KEY_z: m_directionalLight.diffuseIntensity += 0.05f; break; case OGLDEV_KEY_X: case OGLDEV_KEY_x: m_directionalLight.diffuseIntensity -= 0.05f; break; default: break; } }
// Wywo³ywana przy naciœniêciu klawisza void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: glutLeaveMainLoop(); return; case 'w': wPressed = true; carSpeed = FAST_CAR_SPEED; break; case 's': sPressed = true; carSpeed = FAST_CAR_SPEED; break; case 'd': dPressed = true; carSpeed = FAST_CAR_SPEED; break; case 'a': aPressed = true; carSpeed = FAST_CAR_SPEED; break; case 'W': wPressed = true; carSpeed = SLOW_CAR_SPEED; break; case 'S': sPressed = true; carSpeed = SLOW_CAR_SPEED; break; case 'D': dPressed = true; carSpeed = SLOW_CAR_SPEED; break; case 'A': aPressed = true; carSpeed = SLOW_CAR_SPEED; break; case '+': strength += 0.2f; break; case '-': strength -= 0.2f; break; case '8': cutoff += 1; break; case '9': cutoff -= 1; break; case '5': direction[1] += 0.1f; break; case '6': direction[1] -= 0.1f; break; } if (strength < 0.2f) { strength = 0.2f; } else if (strength > 10) { strength = 10; } if (cutoff < 5) { cutoff = 5; } else if (cutoff > 85) { cutoff = 85; } glutPostRedisplay(); }
static void HandleKey(unsigned char key, int pos_x, int pos_y) { (void)pos_x; (void)pos_y; if (key == 'q' || key == 'Q' || key == 27 /* Esc */) { #ifdef FREEGLUT glutLeaveMainLoop(); #else ClearParams(); exit(0); #endif } else if (key == 'c') { if (kParams.has_color_profile && !kParams.decoding_error) { kParams.use_color_profile = 1 - kParams.use_color_profile; if (kParams.has_animation) { // Restart the completed animation to pickup the color profile change. if (kParams.done && kParams.loop_count == 0) { kParams.loop_count = (int)WebPDemuxGetI(kParams.dmux, WEBP_FF_LOOP_COUNT) + 1; kParams.done = 0; // Start the decode loop immediately. glutTimerFunc(0, decode_callback, 0); } } else { Decode(); glutPostRedisplay(); } } } else if (key == 'i') { kParams.print_info = 1 - kParams.print_info; glutPostRedisplay(); } }
void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) { if (cChar == 27) glutLeaveMainLoop(); else if (cChar=='f') { printf("main window toggle fullscreen\n"); glutFullScreenToggle(); } else if (cChar=='r') { printf("main window resize\n"); if (nWidth<400) glutReshapeWindow(600,300); else glutReshapeWindow(300,300); } else if (cChar=='m') { printf("main window position\n"); /* The window position you request is the outer top-left of the window, * the client area is at a different position if the window has borders * and/or a title bar. */ if (nPosX<400) glutPositionWindow(600,300); else glutPositionWindow(300,300); } }
void OS_quit() { SceneManager_destroy(); SceneManager_eventsDestroy(evts); hasQuit = 1; glutLeaveMainLoop(); settings_clear(); }
void keyboard(unsigned char key, int x, int y) { switch (key) { // press esc to exit program case 27: glutLeaveMainLoop(); break; } }
void scan_keys( unsigned char key, int x, int y ) { //ESC key to exit if (key == 27) { glutLeaveGameMode(); glutLeaveMainLoop(); } }
virtual void KeyboardCB(unsigned char Key, int x, int y) { switch (Key) { case 'q': glutLeaveMainLoop(); break; } }
void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: glutLeaveMainLoop(); return; } }
static void Exit(int code) { // TODO: freeglut is not building on OSX #ifdef FREEGLUT glutLeaveMainLoop(); #endif exit(code); }
void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: // esc glutLeaveMainLoop(); //exit(0); break; } }
void keyboard(unsigned char key, int x_pos, int y_pos) { // Handle keyboard input if(key == 27)//ESC { glutLeaveMainLoop(); } }
GlutWindow::~GlutWindow() { #ifdef USEFREEGLUT glutDestroyWindow(windowId); glutLeaveMainLoop(); #endif INSTANCES.erase(windowId); }
void Quit(void) { #if OGLPLUS_FREEGLUT_FOUND glutLeaveMainLoop(); #else exit(0); #endif }
void viewMenu(int value) { switch (value) { case(0) : // "Quit" selected on the menu glutLeaveMainLoop(); break; case(1) : viewingTransformation = glm::translate(glm::vec3(0.0f, 0.0f, -10.0)); break; case(2) : viewingTransformation = glm::translate(glm::vec3(0.0f, 0.0f, -10.0))* glm::rotate(glm::radians(45.0f), glm::vec3(1.0f, 0.0f, 0.0f));// TODO break; case(3) : viewingTransformation = glm::translate(glm::vec3(0.0f, 0.0f, -10.0))* glm::rotate(glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f))* glm::rotate(glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f));// TODO break; case(4) : viewingTransformation = glm::lookAt(glm::vec3(0.0f, 0.0f, 10.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f,1.0f,0.0f)); break; case(5) : viewingTransformation = glm::lookAt(glm::vec3(0.0f, 7.07f, 7.07f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f,1.0f,0.0f)); break; case(6) : viewingTransformation = glm::lookAt(glm::vec3(0.0f, 10.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f)); break; default: cout << "Invalid view selection " << endl; } // Signal GLUT to call display callback glutPostRedisplay(); } // end viewMenu
void keyboard(char key, int x, int y) { switch (key) { case 27: glutLeaveMainLoop(); return; break; } }
void Title::procClick(float x, float y) { int hit = -1; for(int i=0;i<3;++i) { if(_msgButtons[3*_mode+i]->collidesWithPoint(x, y)) { hit = i; break; } } switch(_mode) { case 0: { switch(hit) { case 0: Game::instance()->setNumberOfHumans(1); setMode(1); break; case 1: Game::instance()->setNumberOfHumans(2); setMode(1); break; case 2: glutLeaveMainLoop(); break; default: break; } break; } case 1: { switch(hit) { case 0: Game::instance()->setDifficulty(2); Game::state(Game::GameState::Playing); disable(); break; case 1: Game::instance()->setDifficulty(5); Game::state(Game::GameState::Playing); disable(); break; case 2: setMode(0); break; default: break; } break; } default: break; } }
void getKeyboardDown(unsigned char key, int x, int y) { keyState[key] = true; if (key == 27) { glutLeaveMainLoop(); } }
void KeyboardGL( unsigned char c, int , int ) { switch ( c ) { case 27: glutLeaveMainLoop(); break; } }
//Called whenever a key on the keyboard was pressed. //The key is given by the ''key'' parameter, which is in ASCII. //It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to //exit the program. void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: delete g_pConeMesh; g_pConeMesh = NULL; delete g_pCylinderMesh; g_pCylinderMesh = NULL; delete g_pCubeTintMesh; g_pCubeTintMesh = NULL; delete g_pCubeColorMesh; g_pCubeColorMesh = NULL; delete g_pPlaneMesh; g_pPlaneMesh = NULL; glutLeaveMainLoop(); return; case 'w': g_camTarget.z -= 4.0f; break; case 's': g_camTarget.z += 4.0f; break; case 'd': g_camTarget.x += 4.0f; break; case 'a': g_camTarget.x -= 4.0f; break; case 'e': g_camTarget.y -= 4.0f; break; case 'q': g_camTarget.y += 4.0f; break; case 'W': g_camTarget.z -= 0.4f; break; case 'S': g_camTarget.z += 0.4f; break; case 'D': g_camTarget.x += 0.4f; break; case 'A': g_camTarget.x -= 0.4f; break; case 'E': g_camTarget.y -= 0.4f; break; case 'Q': g_camTarget.y += 0.4f; break; case 'i': g_sphereCamRelPos.y -= 11.25f; break; case 'k': g_sphereCamRelPos.y += 11.25f; break; case 'j': g_sphereCamRelPos.x -= 11.25f; break; case 'l': g_sphereCamRelPos.x += 11.25f; break; case 'o': g_sphereCamRelPos.z -= 5.0f; break; case 'u': g_sphereCamRelPos.z += 5.0f; break; case 'I': g_sphereCamRelPos.y -= 1.125f; break; case 'K': g_sphereCamRelPos.y += 1.125f; break; case 'J': g_sphereCamRelPos.x -= 1.125f; break; case 'L': g_sphereCamRelPos.x += 1.125f; break; case 'O': g_sphereCamRelPos.z -= 0.5f; break; case 'U': g_sphereCamRelPos.z += 0.5f; break; case 'm': MultiplyPlantScale(true); break; case 'n': MultiplyPlantScale(false); break; case 32: g_bDrawLookatPoint = !g_bDrawLookatPoint; printf("Target: %f, %f, %f\n", g_camTarget.x, g_camTarget.y, g_camTarget.z); printf("Position: %f, %f, %f\n", g_sphereCamRelPos.x, g_sphereCamRelPos.y, g_sphereCamRelPos.z); break; } g_sphereCamRelPos.y = glm::clamp(g_sphereCamRelPos.y, -78.75f, -1.0f); g_camTarget.y = g_camTarget.y > 0.0f ? g_camTarget.y : 0.0f; g_sphereCamRelPos.z = g_sphereCamRelPos.z > 5.0f ? g_sphereCamRelPos.z : 5.0f; glutPostRedisplay(); }
void GlutFramework::keyboardDown( unsigned char key, int x, int y ) { // Subclass and override this method // std::cout << "KeyboardDown: " << key << " = " << (int)key << std::endl; if (key==27) { //27 =- ESC key glutLeaveMainLoop(); // exit (0); } }
void TerrainRenderer::paint() { dp::sg::renderer::rix::gl::SceneRendererSharedPtr renderer = getSceneRenderer().staticCast<dp::sg::renderer::rix::gl::SceneRenderer>(); if ( !m_renderEngine.empty() && renderer->getRenderEngine() != m_renderEngine ) { std::cout << "Setting renderengine: " << m_renderEngine << std::endl; renderer->setRenderEngine( m_renderEngine ); } renderer->setShaderManager( m_shaderManager); glPatchParameteri( GL_PATCH_VERTICES, 1 ); // TODO temporary, terrain patch has only 1 'virtual' vertex per patch //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); dp::util::FrameProfiler::instance().beginFrame(); if ( m_benchmarkFrames != ~0 || m_duration != 0.0 ) { if ( m_renderedFrames == 1 ) { m_benchmarkTimer.start(); m_benchmarkProgressTimer.start(); } SceneRendererWidget::paint(); if ( m_benchmarkProgressTimer.getTime() > 1.0 ) { m_benchmarkProgressTimer.restart(); std::ostringstream os; os << "Benchmark Progress: "; if ( m_benchmarkFrames != ~0 ) { os << m_renderedFrames << "/" << m_benchmarkFrames; } else { os << std::setprecision(2) << m_benchmarkTimer.getTime() << "/" << m_duration; } setWindowTitle( os.str() ); } if ( (m_benchmarkFrames != ~0 && m_renderedFrames == m_benchmarkFrames) || (m_duration > 0.0 && m_benchmarkTimer.getTime() > m_duration) ) { m_benchmarkTimer.stop(); m_exitCode = int(double(m_renderedFrames) / m_benchmarkTimer.getTime()); glutLeaveMainLoop(); } // at the end since the first frame does not count ++m_renderedFrames; } else { SceneRendererWidget::paint(); } dp::util::FrameProfiler::instance().endFrame(); }