From 4aaecd5365ca6412f36d8f73d36b9b29abb193e3 Mon Sep 17 00:00:00 2001 From: Sara Gerretsen Date: Thu, 4 Sep 2025 22:17:56 +0200 Subject: [PATCH] fix: view scaling with window --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 9bdc13a..cf4b2de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ static sf::RenderWindow window{}; static sf::Clock deltaClock{}; static AppConfig cfg{}; +static sf::View view{}; extern void configure(AppConfig &config); @@ -16,6 +17,7 @@ void initialize_window() { if (cfg.frame_rate_limit) window.setFramerateLimit(cfg.frame_rate_limit.value_or(0)); window.setVerticalSyncEnabled(cfg.vsync); + view = window.getDefaultView(); } void initialize_imgui() { @@ -28,8 +30,12 @@ void poll_events() { { ImGui::SFML::ProcessEvent(window, *event); // "close requested" event: we close the window - if (event->is()) + if (event->is()) { window.close(); + } else if (sf::Event::Resized const *resized{ event->getIf()}) { + view.setSize({ static_cast(resized->size.x), static_cast(resized->size.y) }); + window.setView(view); + } } }