From cc61194bed324e9fbf51847915357d613a94ff47 Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 1 Jun 2022 16:42:22 -0700 Subject: [PATCH] Move `SDL_ShowWindow` to after assets are loaded This is a minor optimization to streamline the experience of Ved playtesting. Previously, the user would have to wait for all the assets to load when launching playtesting (most of the time, I suspect, is taken up by loading music from a vvvvvvmusic blob). With this optimization, however, the game can be launched in the background and its assets can be loaded, while it blocks on STDIN input. During this time, the user in Ved will be choosing where to start playtesting. After Ved provides STDIN input, then the window will be created and appears instantaneously. This also fixes a related issue in which providing an invalid playtesting level name would result in a brief window flash that gets instantly destroyed. With this, if the level is invalid then no window is ever shown at all. --- desktop_version/src/Screen.cpp | 1 - desktop_version/src/main.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Screen.cpp b/desktop_version/src/Screen.cpp index 709523cc..29a17720 100644 --- a/desktop_version/src/Screen.cpp +++ b/desktop_version/src/Screen.cpp @@ -191,7 +191,6 @@ void Screen::ResizeScreen(int x, int y) return; } } - SDL_ShowWindow(m_window); } void Screen::ResizeToNearestMultiple(void) diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index ab42ce5f..26860faf 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -668,6 +668,9 @@ int main(int argc, char *argv[]) } #endif + /* Only create the window after we have loaded all the assets. */ + SDL_ShowWindow(gameScreen.m_window); + key.isActive = true; gamestate_funcs = get_gamestate_funcs(game.gamestate, &num_gamestate_funcs);