blob: 0e0e12c64a72698f4a51db08fa6de0842ce37b6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* Game plugin.
*
* A game plugin exposes three functions:
* - boot(): called once when the plugin is first loaded during the lifetime of
* the game.
* - init() -> state: creates and returns the plugin's state.
* - update(state): takes and updates the state, possibly with side effects.
* - render(): performs custom rendering.
*
* boot() is convenient for one-time initialization of the scene.
*
* init() is called every time the plugin is loaded. It is assumed that the
* plugin's state is encapsulated in the object returned.
*
* update() updates the plugin state and has side effects on the scene. It is
* assumed that update does not reference any global, mutable state outside of
* the scene and the plugin state returned by init().
*/
#pragma once
#include "../game.h"
#include <gfx/gfx.h>
#include <gfx/scene.h>
#include <stdbool.h>
typedef struct State State;
/// Initialize the plugin's state.
State* init(Game*);
/// Function called the first time the plugin is loaded throughout the
/// application's lifetime. Allows the plugin to do one-time initialization of
/// the game state.
bool boot(State*, Game*);
/// Update the plugin's and the game's state.
void update(State*, Game*, double t, double dt);
/// Optional plugin rendering hook.
void render(State*, const Game*);
// Signatures for the plugin's exposed functions.
typedef void* (*plugin_init)(Game*);
typedef bool (*plugin_boot)(State*, Game*);
typedef void (*plugin_update)(State*, Game*, double t, double dt);
typedef void (*plugin_render)(State*, const Game*);
|