MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / SetFullscreen

Method SetFullscreen

Source/Graphics/graphics.cpp:1629–1697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1627}
1628
1629void Graphics::SetFullscreen(FullscreenMode::Mode val) {
1630 config_.SetFullscreen(val);
1631
1632 // If entering windowed mode, resize the window to half the display resolution and center it,
1633 // Otherwise the title bar (on windows at least) might appear outside of the screen bounds
1634 bool resize = false;
1635 bool recenter = false;
1636
1637 switch (val) {
1638 case FullscreenMode::kWindowed: {
1639 if (currentFullscreenType != FullscreenMode::kWindowed) {
1640 resize = true;
1641 recenter = true;
1642 }
1643
1644 SDL_SetWindowFullscreen(sdl_window_, SDL_FALSE);
1645 SDL_SetWindowBordered(sdl_window_, SDL_TRUE);
1646#if PLATFORM_WINDOWS // Following function added in SDL 2.0.5
1647 SDL_SetWindowResizable(sdl_window_, SDL_TRUE);
1648#endif
1649 break;
1650 }
1651 case FullscreenMode::kFullscreen: {
1652 int w = config_.screen_width();
1653 int h = config_.screen_height();
1654 ResizeWindow(w, h);
1655
1656 SDL_SetWindowFullscreen(sdl_window_, SDL_WINDOW_FULLSCREEN);
1657 break;
1658 }
1659 case FullscreenMode::kWindowed_borderless: {
1660 SDL_SetWindowFullscreen(sdl_window_, SDL_WINDOW_BORDERLESS);
1661 SDL_SetWindowBordered(sdl_window_, SDL_FALSE);
1662#if PLATFORM_WINDOWS // Following function added in SDL 2.0.5
1663 SDL_SetWindowResizable(sdl_window_, SDL_FALSE);
1664#endif
1665 recenter = true;
1666 break;
1667 }
1668 case FullscreenMode::kFullscreen_borderless: {
1669 SDL_SetWindowFullscreen(sdl_window_, SDL_WINDOW_BORDERLESS);
1670 SDL_SetWindowBordered(sdl_window_, SDL_FALSE);
1671#if PLATFORM_WINDOWS // Following function added in SDL 2.0.5
1672 SDL_SetWindowResizable(sdl_window_, SDL_FALSE);
1673#endif
1674
1675 SDL_DisplayMode displayMode;
1676 SDL_GetDesktopDisplayMode(config_.target_monitor(), &displayMode);
1677
1678 ResizeWindow(displayMode.w, displayMode.h); // Recenters window
1679 break;
1680 }
1681 }
1682
1683 if (resize) {
1684 SDL_DisplayMode displayMode;
1685 SDL_GetDesktopDisplayMode(config_.target_monitor(), &displayMode);
1686 SetResolution(displayMode.w / 2, displayMode.h / 2, true);

Callers 4

GraphicsMethod · 0.45
SetFromConfigMethod · 0.45
UpdateFullscreenModeFunction · 0.45
ReloadStaticSettingsMethod · 0.45

Calls 3

screen_widthMethod · 0.80
screen_heightMethod · 0.80
target_monitorMethod · 0.80

Tested by

no test coverage detected