From dd38061d1cdae386b909ad9ec4354e81d58ef972 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 5 Jan 2023 16:42:58 +0300 Subject: [PATCH] Send initial scene resize after the update and before the rendering --- libs/app/source/app.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libs/app/source/app.cpp b/libs/app/source/app.cpp index c5701322..b7baa6ac 100644 --- a/libs/app/source/app.cpp +++ b/libs/app/source/app.cpp @@ -229,15 +229,21 @@ namespace psemek::app auto handler = [this]{ return impl().get_scene(); }; - if (!impl().had_initial_resize) - { - int w, h; - SDL_GetWindowSize(impl().window, &w, &h); - impl().had_initial_resize = true; - handler()->on_resize(w, h); - } + auto send_initial_resize = [this, &handler]{ + if (!impl().had_initial_resize) + { + int w, h; + SDL_GetWindowSize(impl().window, &w, &h); + impl().had_initial_resize = true; + handler()->on_resize(w, h); + } + }; + if (!running()) break; + send_initial_resize(); handler()->update(); + // The handler might have changed during the update + send_initial_resize(); handler()->present(); SDL_GL_SwapWindow(impl().window);