From 4575265a7a927aaf8c9bb175ecefd4ce5e301c27 Mon Sep 17 00:00:00 2001 From: Quentin Bazin Date: Sat, 21 Oct 2023 16:11:26 +0200 Subject: [PATCH] [GameState] Fixed crash when setting fullscreen mode on Windows. --- source/client/states/GameState.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/client/states/GameState.cpp b/source/client/states/GameState.cpp index 801a2cf0..e6450826 100644 --- a/source/client/states/GameState.cpp +++ b/source/client/states/GameState.cpp @@ -170,13 +170,15 @@ void GameState::onEvent(const SDL_Event &event) { } if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { - Config::screenWidth = (u16)event.window.data1; - Config::screenHeight = (u16)event.window.data2; + if (event.window.data1 != 0 && event.window.data2 != 0) { + Config::screenWidth = (u16)event.window.data1; + Config::screenHeight = (u16)event.window.data2; - m_camera.setAspectRatio((float)Config::screenWidth / Config::screenHeight); - m_hud.setup(); + m_camera.setAspectRatio((float)Config::screenWidth / Config::screenHeight); + m_hud.setup(); - m_fbo.init(Config::screenWidth, Config::screenHeight); + m_fbo.init(Config::screenWidth, Config::screenHeight); + } } }