Send initial scene resize after the update and before the rendering

This commit is contained in:
Nikita Lisitsa 2023-01-05 16:42:58 +03:00
parent 1241fdff9c
commit dd38061d1c

View file

@ -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);