void GourceShell::keyPress(SDL_KeyboardEvent *e) { bool repeat = false; #if SDL_VERSION_ATLEAST(2,0,0) repeat = (e->repeat > 0); #endif //Quit demo if the user presses ESC if (e->type == SDL_KEYDOWN && !repeat) { #if SDL_VERSION_ATLEAST(2,0,0) bool key_escape = e->keysym.sym == SDLK_ESCAPE; bool key_return = e->keysym.sym == SDLK_RETURN; #else bool key_escape = e->keysym.unicode == SDLK_ESCAPE; bool key_return = e->keysym.unicode == SDLK_RETURN; #endif if (key_escape) { quit(); } if (e->keysym.sym == SDLK_F11) { toggleWindowFrame(); } if(key_return) { #if SDL_VERSION_ATLEAST(2,0,0) const Uint8* keystate = SDL_GetKeyboardState(NULL); if(keystate[SDL_SCANCODE_RALT] || keystate[SDL_SCANCODE_LALT]) { #else Uint8* keystate = SDL_GetKeyState(NULL); if(keystate[SDLK_RALT] || keystate[SDLK_LALT]) { #endif toggleFullscreen(); } else { if(gGourceSettings.repo_count>1) next = true; } } } if(gource!=0) gource->keyPress(e); } void GourceShell::mouseMove(SDL_MouseMotionEvent *e) { if(gource!=0) gource->mouseMove(e); } #if SDL_VERSION_ATLEAST(2,0,0) void GourceShell::mouseWheel(SDL_MouseWheelEvent *e) { if(gource!=0) gource->mouseWheel(e); } #endif void GourceShell::mouseClick(SDL_MouseButtonEvent *e) { if(gource!=0) gource->mouseClick(e); } void GourceShell::quit() { if(gource!=0) gource->quit(); gGourceSettings.shutdown=true; } Gource* GourceShell::getNext() { if(gource!=0) { transition_interval = 1.0f; } if(gGourceSettings.shutdown || gource_settings == conf->getSections("gource")->end()) { // if we are done, delete gource and replace it with nothing if(gource != 0) { Gource* gource_tmp = gource; gource = 0; delete gource_tmp; } return 0; } gGourceSettings.importGourceSettings(*conf, *gource_settings); //recording a video kind of implies you want this, unless: // -- dont stop requested // -- loop requested // -- reading from STDIN if(exporter!=0 && !(gGourceSettings.dont_stop || gGourceSettings.loop || gGourceSettings.path == "-")) gGourceSettings.stop_at_end = true; //multiple repo special settings if(gGourceSettings.repo_count > 1) { //set a stop condition if(gGourceSettings.stop_at_time <= 0.0f && gGourceSettings.stop_position <= 0.0f) { gGourceSettings.stop_at_time = 60.0f; } } gource_settings++; //loop unless only 1 repo if(gource_settings == conf->getSections("gource")->end()) { if(gGourceSettings.repo_count>1 && exporter==0) { gource_settings = conf->getSections("gource")->begin(); } } // replace gource Gource* gource_tmp = gource; gource = new Gource(exporter); delete gource_tmp; next = false; return gource; } void GourceShell::blendLastFrame(float dt) { if(transition_texture==0 || transition_interval <= 0.0f) return; display.mode2D(); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); transition_texture->bind(); glColor4f(1.0, 1.0, 1.0, transition_interval); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 0.0); glTexCoord2f(1.0, 1.0f); glVertex2f(display.width, 0.0); glTexCoord2f(1.0, 0.0f); glVertex2f(display.width, display.height); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, display.height); glEnd(); transition_interval -= dt; } void GourceShell::update(float t, float dt) { if(gource == 0 || gource->isFinished()) { if(!getNext()) appFinished=true; return; } gource->fps = this->fps; gource->update(t, dt); if(toggle_delay > 0.0) toggle_delay -= dt; //copy last frame if( (next|| gource->isFinished()) && transition_texture!=0) { if(gGourceSettings.screenshot_at_end) gource->screenshot(); glEnable(GL_TEXTURE_2D); transition_texture->bind(); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, display.width, display.height, 0); } else { //blend last frame of previous scene blendLastFrame(dt); } if(next) { delete gource; gource = 0; transition_interval = 1.0f; next = false; } }
void Logstalgia::keyPress(SDL_KeyboardEvent *e) { if (e->type == SDL_KEYDOWN) { if (e->keysym.sym == SDLK_ESCAPE) { appFinished=true; } if(e->keysym.sym == SDLK_q) { info = !info; } if(e->keysym.sym == SDLK_c) { settings.splash = 10.0f; } if(e->keysym.sym == SDLK_n) { next = true; } if (e->keysym.sym == SDLK_p) { if(GLEW_VERSION_2_0) { settings.ffp = !settings.ffp; } } if(e->keysym.sym == SDLK_SPACE) { togglePause(); } if (e->keysym.sym == SDLK_F11) { toggleWindowFrame(); } if (e->keysym.sym == SDLK_F12) { take_screenshot = true; } if(!settings.sync) { if (e->keysym.sym == SDLK_EQUALS || e->keysym.sym == SDLK_KP_PLUS) { if(settings.simulation_speed >= 1.0f) { settings.simulation_speed = std::min(30.0f, glm::floor(settings.simulation_speed) + 1.0f); } else { settings.simulation_speed = std::min(1.0f, settings.simulation_speed * 2.0f); } retarget=true; } if (e->keysym.sym == SDLK_MINUS || e->keysym.sym == SDLK_KP_MINUS) { if(settings.simulation_speed > 1.0f) { settings.simulation_speed = std::max(1.0f, glm::floor(settings.simulation_speed) - 1.0f); } else { settings.simulation_speed = std::max(0.1f, settings.simulation_speed * 0.5f); } retarget=true; } } if(e->keysym.sym == SDLK_PERIOD) { settings.pitch_speed = glm::clamp(settings.pitch_speed+0.1f, 0.0f, 10.0f); retarget=true; } if(e->keysym.sym == SDLK_COMMA) { settings.pitch_speed = glm::clamp(settings.pitch_speed-0.1f, 0.1f, 10.0f); retarget=true; } if(e->keysym.sym == SDLK_RETURN && e->keysym.mod & KMOD_ALT) { toggleFullscreen(); } } }