diff options
| author | 3gg <3gg@shellblade.net> | 2024-01-20 15:54:54 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2024-01-20 15:54:54 -0800 |
| commit | 3cd5b0bcca694630fcb4b977ddf7be7cd1bce153 (patch) | |
| tree | e1a0e02ab5471d0f2ffb499f18109d6790241798 /game/src/plugins/plugin.h | |
| parent | 02ec7cd07213e267fda7e1e67b62f55e92a2f32c (diff) | |
Rename gltfview -> game.
Diffstat (limited to 'game/src/plugins/plugin.h')
| -rw-r--r-- | game/src/plugins/plugin.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/game/src/plugins/plugin.h b/game/src/plugins/plugin.h new file mode 100644 index 0000000..a2632cd --- /dev/null +++ b/game/src/plugins/plugin.h | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | /* | ||
| 2 | * Game plugin. | ||
| 3 | */ | ||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "../game.h" | ||
| 7 | |||
| 8 | #include <gfx/gfx.h> | ||
| 9 | #include <gfx/scene.h> | ||
| 10 | |||
| 11 | #include <stdbool.h> | ||
| 12 | |||
| 13 | typedef struct State State; | ||
| 14 | |||
| 15 | /// Initialize the plugin, which may optionally return a state object. | ||
| 16 | /// | ||
| 17 | /// This function is called every time the plugin is (re)loaded. | ||
| 18 | /// | ||
| 19 | /// It is assumed that the plugin's state is fully encapsulated in the returned | ||
| 20 | /// state object. The plugin should not store any (mutable) state outside of the | ||
| 21 | /// returned state object (e.g., no mutable global variables.) | ||
| 22 | bool init(Game*, State**); | ||
| 23 | |||
| 24 | /// Shut down the plugin. | ||
| 25 | /// | ||
| 26 | /// This function is called before the plugin is unloaded. | ||
| 27 | /// | ||
| 28 | /// The plugin should perform any destruction needed, but not free the state | ||
| 29 | /// object; freeing the state object's memory is handled by the caller. | ||
| 30 | void shutdown(Game*, State*); | ||
| 31 | |||
| 32 | /// Function called the first time the plugin is loaded throughout the | ||
| 33 | /// application's lifetime. This allows the plugin to do one-time initialization | ||
| 34 | /// of the game state. | ||
| 35 | bool boot(Game*, State*); | ||
| 36 | |||
| 37 | /// Update the plugin's and the game's state. | ||
| 38 | void update(Game*, State*, double t, double dt); | ||
| 39 | |||
| 40 | /// Render hook. | ||
| 41 | void render(const Game*, const State*); | ||
| 42 | |||
| 43 | /// Called when the game's window is resized. | ||
| 44 | void resize(Game* game, State* state, int width, int height); | ||
| 45 | |||
| 46 | // Signatures for the plugin's exposed functions. | ||
| 47 | typedef bool (*plugin_init)(Game*, State**); | ||
| 48 | typedef bool (*plugin_shutdown)(Game*, State*); | ||
| 49 | typedef bool (*plugin_boot)(Game*, State*); | ||
| 50 | typedef void (*plugin_update)(Game*, State*, double t, double dt); | ||
| 51 | typedef void (*plugin_render)(const Game*, const State*); | ||
| 52 | typedef void (*plugin_resize)(Game* game, State* state, int width, int height); | ||
