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); + } } }