MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ToggleFullscreen

Method ToggleFullscreen

src/video/sdl2_v.cpp:690–718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688}
689
690bool VideoDriver_SDL_Base::ToggleFullscreen(bool fullscreen)
691{
692 /* Remember current window size */
693 int w, h;
694 SDL_GetWindowSize(this->sdl_window, &w, &h);
695
696 if (fullscreen) {
697 /* Find fullscreen window size */
698 SDL_DisplayMode dm;
699 if (SDL_GetCurrentDisplayMode(SDL_GetWindowDisplayIndex(this->sdl_window), &dm) < 0) {
700 Debug(driver, 0, "SDL_GetCurrentDisplayMode() failed: {}", SDL_GetError());
701 } else {
702 SDL_SetWindowSize(this->sdl_window, dm.w, dm.h);
703 }
704 }
705
706 Debug(driver, 1, "SDL2: Setting {}", fullscreen ? "fullscreen" : "windowed");
707 int ret = SDL_SetWindowFullscreen(this->sdl_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
708 if (ret == 0) {
709 /* Switching resolution succeeded, set fullscreen value of window. */
710 _fullscreen = fullscreen;
711 if (!fullscreen) SDL_SetWindowSize(this->sdl_window, w, h);
712 } else {
713 Debug(driver, 0, "SDL_SetWindowFullscreen() failed: {}", SDL_GetError());
714 }
715
716 InvalidateWindowClassesData(WC_GAME_OPTIONS, 3);
717 return ret == 0;
718}
719
720bool VideoDriver_SDL_Base::AfterBlitterChange()
721{

Callers 1

ToggleFullScreenFunction · 0.45

Calls 1

Tested by

no test coverage detected