Kohi Game Engine
plugin_system.h
Go to the documentation of this file.
1 #ifndef _KOHI_PLUGIN_SYSTEM_H_
2 #define _KOHI_PLUGIN_SYSTEM_H_
3 
4 #include "defines.h"
5 #include "parsers/kson_parser.h"
6 #include "plugins/plugin_types.h"
7 
8 // Build up a system that can load plugins by configured names,
9 // which is then uses to load shared libraries. It will then load up the
10 // found kruntime_plugin functions that are available, setup the state
11 // and register it as globally available to be queried later.
12 // This should happen early in the bootup process so systems that have
13 // backend plugins (audio, renderer, etc) have what they need by init time.
14 
15 struct plugin_system_state;
16 
18  // Name of the plugin.
19  const char* name;
20  // To be deserialized by the plugin itself since it knows how this should be laid out.
21  const char* config_str;
23 
27 typedef struct plugin_system_config {
28  // darray The collection of plugin configs.
31 
32 struct frame_data;
33 struct kwindow;
34 
35 b8 plugin_system_deserialize_config(const char* config_str, plugin_system_config* out_config);
37 
38 b8 plugin_system_intialize(u64* memory_requirement, struct plugin_system_state* state, struct plugin_system_config* config);
39 
40 void plugin_system_shutdown_all_plugins(struct plugin_system_state* state);
41 void plugin_system_shutdown(struct plugin_system_state* state);
42 
43 b8 plugin_system_initialize_plugins(struct plugin_system_state* state);
44 b8 plugin_system_update_plugins(struct plugin_system_state* state, struct frame_data* p_frame_data);
45 b8 plugin_system_frame_prepare_plugins(struct plugin_system_state* state, struct frame_data* p_frame_data);
46 b8 plugin_system_render_plugins(struct plugin_system_state* state, struct frame_data* p_frame_data);
47 
48 b8 plugin_system_on_window_resize_plugins(struct plugin_system_state* state, struct kwindow* window, u16 width, u16 height);
49 
50 KAPI b8 plugin_system_load_plugin(struct plugin_system_state* state, const char* name, const char* config);
51 
52 KAPI kruntime_plugin* plugin_system_get(struct plugin_system_state* state, const char* name);
53 
54 #endif
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:209
_Bool b8
8-bit boolean type
Definition: defines.h:60
unsigned short u16
Unsigned 16-bit integer.
Definition: defines.h:24
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:30
This file contains the parser implementation for the KSON (Kohi Storage Object Notation) file format.
void plugin_system_destroy_config(plugin_system_config *out_config)
struct plugin_system_plugin_config plugin_system_plugin_config
b8 plugin_system_render_plugins(struct plugin_system_state *state, struct frame_data *p_frame_data)
b8 plugin_system_on_window_resize_plugins(struct plugin_system_state *state, struct kwindow *window, u16 width, u16 height)
b8 plugin_system_frame_prepare_plugins(struct plugin_system_state *state, struct frame_data *p_frame_data)
b8 plugin_system_initialize_plugins(struct plugin_system_state *state)
b8 plugin_system_update_plugins(struct plugin_system_state *state, struct frame_data *p_frame_data)
void plugin_system_shutdown(struct plugin_system_state *state)
b8 plugin_system_intialize(u64 *memory_requirement, struct plugin_system_state *state, struct plugin_system_config *config)
b8 plugin_system_deserialize_config(const char *config_str, plugin_system_config *out_config)
struct plugin_system_config plugin_system_config
KAPI b8 plugin_system_load_plugin(struct plugin_system_state *state, const char *name, const char *config)
void plugin_system_shutdown_all_plugins(struct plugin_system_state *state)
KAPI kruntime_plugin * plugin_system_get(struct plugin_system_state *state, const char *name)
Engine-level current frame-specific data.
Definition: frame_data.h:15
Definition: plugin_types.h:33
Represents a window in the application.
Definition: platform.h:71
u16 height
The height of the window in pixels.
Definition: platform.h:80
u16 width
The width of the window in pixels.
Definition: platform.h:78
const char * name
The internal name of the window.
Definition: platform.h:73
Definition: plugin_system.h:27
plugin_system_plugin_config * plugins
Definition: plugin_system.h:29
Definition: plugin_system.h:17
const char * config_str
Definition: plugin_system.h:21
const char * name
Definition: plugin_system.h:19