summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2023-02-04 11:08:43 -0800
committer3gg <3gg@shellblade.net>2023-02-04 11:08:43 -0800
commit4eee2853cb38892283fffc939b8f2d4e540c0d30 (patch)
tree8d5edd7f86bf8f10507ed9017cbc810bff20381d
parent9f57fe66fb638be0566fb78dc75d74b8a650f725 (diff)
Warm up application update function before first render.
-rw-r--r--gfx-app/include/gfx/gfx_app.h12
-rw-r--r--gfx-app/src/gfx_app.c8
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 @@
3#include <stdbool.h> 3#include <stdbool.h>
4 4
5typedef struct GfxAppDesc { 5typedef struct GfxAppDesc {
6 int argc; // Number of application arguments. 6 int argc; // Number of application arguments.
7 const char** argv; // Application arguments. 7 const char** argv; // Application arguments.
8 int width; // Window width. 8 int width; // Window width.
9 int height; // Window height. 9 int height; // Window height.
10 int max_fps; // Desired maximum framerate. 0 to disable. 10 int max_fps; // Desired maximum display framerate. 0 to disable.
11 double update_delta_time; // Desired delta time between frame updates. 11 double update_delta_time; // Desired delta time between frame updates.
12} GfxAppDesc; 12} GfxAppDesc;
13 13
14typedef struct GfxAppCallbacks { 14typedef 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) {
37 double time_budget = 0.0; 37 double time_budget = 0.0;
38 Timer timer = timer_make(); 38 Timer timer = timer_make();
39 39
40 // Warm up the rendering before entering the main loop. A renderer can compile 40 // Warm up the update to initialize the application's state.
41 // shaders and do other initialization the first time it renders a scene. 41 (*app->callbacks.update)(app->app_state, time, update_dt);
42
43 // Warm up the rendering before entering the main loop. A renderer can
44 // compile shaders and do other initialization the first time it renders a
45 // scene.
42 (*app->callbacks.render)(app->app_state); 46 (*app->callbacks.render)(app->app_state);
43 glfwSwapBuffers(app->window); 47 glfwSwapBuffers(app->window);
44 48