Kohi Game Engine
testbed_types.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "core/keymap.h"
4 #include "debug_console.h"
5 #include "defines.h"
6 #include "editor/editor.h"
7 #include "kui_system.h"
9 #include "renderer/kui_renderer.h"
10 #include "systems/kcamera_system.h"
11 #include "time/kclock.h"
12 
14 #include <utils_plugin_defines.h>
15 
16 #if KOHI_DEBUG
17 # define testbed_EDITOR 1
18 #endif
19 
20 #define PACKAGE_NAME_TESTBED "Testbed"
21 
22 typedef enum testbed_app_mode {
24 #ifdef testbed_EDITOR
25  TESTBED_APP_MODE_EDITOR,
26 #endif
30 
32  switch (mode) {
33  default:
35  return "WORLD";
36  case TESTBED_APP_MODE_EDITOR:
37  return "EDITOR";
39  return "MAIN_MENU";
41  return "PAUSE";
42  }
43 }
44 
45 // User-defined codes to be used with the event system.
46 typedef enum game_event_code {
47  // Start of the User-defined code range. Not an actual used code.
50 
58 
59  /*
60  * @brief An event fired when context sensitivity text should be displayed.
61  *
62  * Context usage: N/A
63  */
65 
67 
68 typedef struct game_state_serializable {
71 
72 typedef struct game_constants {
74  // TODO: Get rid of this in favour of mouse-pos-based rotation/gamepad right stick rotations.
77 
78 // Represents the actual state of the game; serialized to disk on game save.
79 typedef struct game_state {
80 
83 
85 
86 #ifdef testbed_EDITOR
87 struct editor_state;
88 #endif
89 
90 typedef struct application_state {
92  // Used as the default for rendering the world.
95 
98 
99  // The current mode of the game, which controls input, etc.
101 
103 
106  struct kscene* current_scene;
107 
108  // Pointers to engine systems.
109  struct kaudio_system_state* audio_system;
113 
118 
119  // The forward game renderer.
122 
125 
127 
128  // Previous frame allocator memory allocated
130  // Previous frame allocator total memory (in case it changes)
132 
133  // NOTE: Debug stuff to eventually be excluded on release builds.
134 #ifdef KOHI_DEBUG
135  kui_control debug_text;
136  kui_control debug_text_shadow;
137  debug_console_state debug_console;
138  keymap console_keymap;
139 #endif
140 
142 
143  struct item_db* db;
144 
145  // UI state
147 
148 #ifdef KOHI_EDITOR
149  struct editor_state* editor;
150 #endif
152 
153 struct testbed_render_data;
154 
155 typedef struct application_frame_data {
156  struct testbed_render_data* render_data;
This file contains global type definitions which are used throughout the entire engine and applicatio...
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:27
_Bool b8
8-bit boolean type
Definition: defines.h:60
float f32
32-bit floating point number
Definition: defines.h:49
double f64
64-bit floating point number
Definition: defines.h:52
unsigned short u16
Unsigned 16-bit integer.
Definition: defines.h:24
#define KINLINE
Inline qualifier.
Definition: defines.h:256
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:30
u8 kcamera
Definition: kcamera_system.h:28
This file contains structures and functions for the engine's clock.
This file contains the structures and functions required to implement keymaps and keybindings,...
u64 kname
A kname is a string hash made for quick comparisons versus traditional string comparisons.
Definition: kname.h:36
Definition: testbed_types.h:155
struct testbed_render_data * render_data
Definition: testbed_types.h:156
Definition: testbed_types.h:90
kclock render_clock
Definition: testbed_types.h:116
kclock prepare_clock
Definition: testbed_types.h:115
keymap world_keymap
Definition: testbed_types.h:97
struct kui_plugin_state * kui_plugin_state
Definition: testbed_types.h:111
struct kaudio_system_state * audio_system
Definition: testbed_types.h:109
u64 prev_framealloc_allocated
Definition: testbed_types.h:129
u16 height
Definition: testbed_types.h:102
testbed_application_mode mode
Definition: testbed_types.h:100
kforward_renderer game_renderer
Definition: testbed_types.h:120
u16 width
Definition: testbed_types.h:102
kname scene_package_name
Definition: testbed_types.h:105
keymap global_keymap
Definition: testbed_types.h:96
kui_control context_sensitive_text
Definition: testbed_types.h:146
mat4 ui_projection
Definition: testbed_types.h:124
u64 prev_framealloc_total
Definition: testbed_types.h:131
struct item_db * db
Definition: testbed_types.h:143
kname scene_name
Definition: testbed_types.h:104
kui_renderer kui_renderer
Definition: testbed_types.h:121
kcamera ui_camera
Definition: testbed_types.h:94
struct kruntime_plugin * kui_plugin
Definition: testbed_types.h:110
struct kui_state * kui_state
Definition: testbed_types.h:112
kclock update_clock
Definition: testbed_types.h:114
b8 running
Definition: testbed_types.h:91
f64 last_update_elapsed
Definition: testbed_types.h:117
u32 render_mode
Definition: testbed_types.h:126
kcamera world_camera
Definition: testbed_types.h:93
mat4 world_projection
Definition: testbed_types.h:123
game_state game
Definition: testbed_types.h:141
struct kscene * current_scene
Definition: testbed_types.h:106
Definition: editor.h:45
Definition: testbed_types.h:72
f32 base_movement_speed
Definition: testbed_types.h:73
f32 turn_speed
Definition: testbed_types.h:75
Definition: testbed_types.h:68
u64 time_played_seconds
Definition: testbed_types.h:69
Definition: testbed_types.h:79
game_state_serializable serializable
Definition: testbed_types.h:81
game_constants constants
Definition: testbed_types.h:82
Represents a basic clock, which can be used to track time deltas in the system.
Definition: kclock.h:20
A keymap, which holds a list of keymap entries, each with a list of bindings. These are held in an in...
Definition: keymap.h:103
Represents the state of the Kohi Default Forward application renderer.
Definition: kforward_renderer.h:68
Definition: plugin_types.h:33
struct application_state application_state
KINLINE const char * testbed_application_mode_to_string(testbed_application_mode mode)
Definition: testbed_types.h:31
testbed_app_mode
Definition: testbed_types.h:22
@ TESTBED_APP_MODE_PAUSE_MENU
Definition: testbed_types.h:28
@ TESTBED_APP_MODE_WORLD
Definition: testbed_types.h:23
@ TESTBED_APP_MODE_MAIN_MENU
Definition: testbed_types.h:27
enum testbed_app_mode testbed_application_mode
game_event_code
Definition: testbed_types.h:46
@ GAME_EVENT_CODE_START
Definition: testbed_types.h:48
@ GAME_EVENT_CODE_UNUSED
Definition: testbed_types.h:49
@ GAME_EVENT_CODE_HIDE_CONTEXT_DISPLAY
Definition: testbed_types.h:64
@ GAME_EVENT_CODE_SHOW_CONTEXT_DISPLAY
An event fired when context sensitivity text should be displayed.
Definition: testbed_types.h:57
struct game_state_serializable game_state_serializable
struct application_frame_data application_frame_data
struct game_constants game_constants
struct game_state game_state
a 4x4 matrix, typically used to represent object transformations.
Definition: math_types.h:383