summaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/core.c b/src/core.c
index cd6ff88..3596e01 100644
--- a/src/core.c
+++ b/src/core.c
@@ -13,25 +13,28 @@
#define SCR_WIDTH 1000
#define SCR_HEIGHT 1000
-core* core_bringup() {
+core g_core; /** @brief global `core` that other files can use */
+
+inline core* get_global_core() { return &g_core; }
+
+void core_bringup() {
INFO("Initiate Core bringup");
- core* c = malloc(sizeof(core));
renderer_config conf = { .window_name = { "Celeritas Engine Core" },
.scr_width = SCR_WIDTH,
.scr_height = SCR_HEIGHT,
.clear_colour = (vec3){ .08, .08, .1 } };
- c->renderer.config = conf;
- c->renderer.backend_context = NULL;
+ g_core.renderer.config = conf;
+ g_core.renderer.backend_context = NULL;
// threadpool_create(&c->threadpool, 6, 256);
// threadpool_set_ctx(&c->threadpool, c); // Gives the threadpool access to the core
// initialise all subsystems
- if (!renderer_init(&c->renderer)) {
+ if (!renderer_init(&g_core.renderer)) {
// FATAL("Failed to start renderer");
ERROR_EXIT("Failed to start renderer\n");
}
- if (!input_system_init(&c->input, c->renderer.window)) {
+ if (!input_system_init(&g_core.input, g_core.renderer.window)) {
// the input system needs the glfw window which is created by the renderer
// hence the order here is important
FATAL("Failed to start input system");
@@ -48,26 +51,22 @@ core* core_bringup() {
}
*/
- c->models = model_darray_new(10);
-
- return c;
+ g_core.models = model_darray_new(10);
}
#include <glfw3.h>
-#include "input.h"
-#include "render.h"
bool should_window_close(core* core) { glfwWindowShouldClose(core->renderer.window); }
-void core_input_update(core* core) { input_update(&core->input); }
+void core_input_update() { input_update(&g_core.input); }
void core_frame_begin(core* core) { render_frame_begin(&core->renderer); }
void core_frame_end(core* core) { render_frame_end(&core->renderer); }
-void core_shutdown(core* core) {
+void core_shutdown() {
// threadpool_destroy(&core->threadpool);
- input_system_shutdown(&core->input);
- renderer_shutdown(&core->renderer);
+ input_system_shutdown(&g_core.input);
+ renderer_shutdown(&g_core.renderer);
}
-bool should_exit(core* core) {
- return key_just_released(KEYCODE_ESCAPE) || glfwWindowShouldClose(core->renderer.window);
-} \ No newline at end of file
+bool should_exit() {
+ return key_just_released(KEYCODE_ESCAPE) || glfwWindowShouldClose(g_core.renderer.window);
+}