Browse Source

Fix fullscreen toggling when initially starting in fullscreen mode.

master
C. J. Howard 5 years ago
parent
commit
64a917b880
Signed by: cjhoward GPG Key ID: 03E1FABA9C3EC195
2 changed files with 18 additions and 1 deletions
  1. +0
    -1
      README.md
  2. +18
    -0
      src/game.cpp

+ 0
- 1
README.md View File

@ -15,4 +15,3 @@ The source code for Antkeeper is licensed under the GNU General Public License,
| OpenAL soft | | GNU GPL v2.0 | | | OpenAL soft | | GNU GPL v2.0 | |
| stb_image | Sean Barrett | Public Domain / MIT License | [`stb_image.h`](./src/stb/stb_image.h) | | stb_image | Sean Barrett | Public Domain / MIT License | [`stb_image.h`](./src/stb/stb_image.h) |
| stb_image_writer | Sean Barrett | Public Domain / MIT License | [`stb_image_writer.h`](./src/stb/stb_image_writer.h) | | stb_image_writer | Sean Barrett | Public Domain / MIT License | [`stb_image_writer.h`](./src/stb/stb_image_writer.h) |

+ 18
- 0
src/game.cpp View File

@ -537,6 +537,24 @@ void Game::toggleFullscreen()
{ {
fullscreen = !fullscreen; fullscreen = !fullscreen;
window->setFullscreen(fullscreen); window->setFullscreen(fullscreen);
if (!fullscreen)
{
const Display* display = deviceManager->getDisplays()->front();
int displayWidth = std::get<0>(display->getDimensions());
int displayHeight = std::get<1>(display->getDimensions());
w = static_cast<int>(windowedResolution.x);
h = static_cast<int>(windowedResolution.y);
// Determine window position
int x = std::get<0>(display->getPosition()) + displayWidth / 2 - w / 2;
int y = std::get<1>(display->getPosition()) + displayHeight / 2 - h / 2;
window->setDimensions(w, h);
window->setPosition(x, y);
}
restringUI(); restringUI();
// Disable fullscreen toggles for 500ms // Disable fullscreen toggles for 500ms

Loading…
Cancel
Save