/* * 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 #include #include 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*);