summaryrefslogtreecommitdiff
path: root/gltfview/src/plugins/plugin.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2023-06-16 09:38:15 -0700
committer3gg <3gg@shellblade.net>2023-06-16 09:38:15 -0700
commit520e4e67cd9ff53f3c3512c80d07193625e07e3e (patch)
treef2f8acfc2eb0d2aa279263d93af00beef7e93a1b /gltfview/src/plugins/plugin.h
parent14e6edd6bfe94089d52b5c4b6899dea23923e9be (diff)
New plugin architecture.
Diffstat (limited to 'gltfview/src/plugins/plugin.h')
-rw-r--r--gltfview/src/plugins/plugin.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/gltfview/src/plugins/plugin.h b/gltfview/src/plugins/plugin.h
new file mode 100644
index 0000000..0e0e12c
--- /dev/null
+++ b/gltfview/src/plugins/plugin.h
@@ -0,0 +1,49 @@
1/*
2 * Game plugin.
3 *
4 * A game plugin exposes three functions:
5 * - boot(): called once when the plugin is first loaded during the lifetime of
6 * the game.
7 * - init() -> state: creates and returns the plugin's state.
8 * - update(state): takes and updates the state, possibly with side effects.
9 * - render(): performs custom rendering.
10 *
11 * boot() is convenient for one-time initialization of the scene.
12 *
13 * init() is called every time the plugin is loaded. It is assumed that the
14 * plugin's state is encapsulated in the object returned.
15 *
16 * update() updates the plugin state and has side effects on the scene. It is
17 * assumed that update does not reference any global, mutable state outside of
18 * the scene and the plugin state returned by init().
19 */
20#pragma once
21
22#include "../game.h"
23
24#include <gfx/gfx.h>
25#include <gfx/scene.h>
26
27#include <stdbool.h>
28
29typedef struct State State;
30
31/// Initialize the plugin's state.
32State* init(Game*);
33
34/// Function called the first time the plugin is loaded throughout the
35/// application's lifetime. Allows the plugin to do one-time initialization of
36/// the game state.
37bool boot(State*, Game*);
38
39/// Update the plugin's and the game's state.
40void update(State*, Game*, double t, double dt);
41
42/// Optional plugin rendering hook.
43void render(State*, const Game*);
44
45// Signatures for the plugin's exposed functions.
46typedef void* (*plugin_init)(Game*);
47typedef bool (*plugin_boot)(State*, Game*);
48typedef void (*plugin_update)(State*, Game*, double t, double dt);
49typedef void (*plugin_render)(State*, const Game*);