From 0c7c29d669c16c3821b19d00a9319f3eba5cf05d Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 1 Feb 2025 15:24:19 +0500 Subject: feat: update view on resize --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 0ac1b21..3eb444c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,15 @@ int main() { ImGui::SFML::ProcessEvent(window, e); } + // (cv pasted from + // https://www.sfml-dev.org/tutorials/3.0/graphics/view/#showing-more-when-the-window-is-resized) + // catch the resize events + if (const auto* resized = event->getIf()) { + // update the view to the new size of the window + sf::FloatRect visibleArea({0.f, 0.f}, sf::Vector2f(resized->size)); + window.setView(sf::View(visibleArea)); + } + if (event->is()) { window.close(); } -- cgit v1.2.3