From 4eee2853cb38892283fffc939b8f2d4e540c0d30 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 4 Feb 2023 11:08:43 -0800 Subject: Warm up application update function before first render. --- gfx-app/include/gfx/gfx_app.h | 12 ++++++------ gfx-app/src/gfx_app.c | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gfx-app/include/gfx/gfx_app.h b/gfx-app/include/gfx/gfx_app.h index bdb3550..4744992 100644 --- a/gfx-app/include/gfx/gfx_app.h +++ b/gfx-app/include/gfx/gfx_app.h @@ -3,12 +3,12 @@ #include typedef struct GfxAppDesc { - int argc; // Number of application arguments. - const char** argv; // Application arguments. - int width; // Window width. - int height; // Window height. - int max_fps; // Desired maximum framerate. 0 to disable. - double update_delta_time; // Desired delta time between frame updates. + int argc; // Number of application arguments. + const char** argv; // Application arguments. + int width; // Window width. + int height; // Window height. + int max_fps; // Desired maximum display framerate. 0 to disable. + double update_delta_time; // Desired delta time between frame updates. } GfxAppDesc; typedef struct GfxAppCallbacks { diff --git a/gfx-app/src/gfx_app.c b/gfx-app/src/gfx_app.c index 018e997..31f8448 100644 --- a/gfx-app/src/gfx_app.c +++ b/gfx-app/src/gfx_app.c @@ -37,8 +37,12 @@ static void loop(GfxApp* app) { double time_budget = 0.0; Timer timer = timer_make(); - // Warm up the rendering before entering the main loop. A renderer can compile - // shaders and do other initialization the first time it renders a scene. + // Warm up the update to initialize the application's state. + (*app->callbacks.update)(app->app_state, time, update_dt); + + // Warm up the rendering before entering the main loop. A renderer can + // compile shaders and do other initialization the first time it renders a + // scene. (*app->callbacks.render)(app->app_state); glfwSwapBuffers(app->window); -- cgit v1.2.3