summaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
authorJoshua Rowe <17525998+omnisci3nce@users.noreply.github.com>2024-05-20 10:50:11 +1000
committerGitHub <noreply@github.com>2024-05-20 10:50:11 +1000
commite904c22003c3a134201b222e6619e782fbe63947 (patch)
tree5295c8ce5f855ca4a0f1bebe50beee80bae66682 /src/core.c
parent02e84ee4d18e705e3362be1e327fdb6f1397a032 (diff)
parent73d4145f46d2305f45761b8e456df692d1962dfb (diff)
Merge pull request #14 from omnisci3nce/realign
Realign
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c56
1 files changed, 43 insertions, 13 deletions
diff --git a/src/core.c b/src/core.c
index 024b2d7..84c9cae 100644
--- a/src/core.c
+++ b/src/core.c
@@ -2,33 +2,40 @@
#include <stdlib.h>
+#include "glfw3.h"
+#include "input.h"
+#include "keys.h"
#include "log.h"
#include "render.h"
#include "render_types.h"
-#include "threadpool.h"
+#include "scene.h"
+// #include "threadpool.h"
-#define SCR_WIDTH 1080
-#define SCR_HEIGHT 800
+#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_state = 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
+ // 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");
@@ -45,7 +52,30 @@ core* core_bringup() {
}
*/
- c->models = model_darray_new(10);
+ INFO("Creating default scene");
+ scene_init(&g_core.default_scene);
+}
+
+#include <glfw3.h>
+
+/* bool should_window_close(core* core) { glfwWindowShouldClose(core->renderer.window); } */
+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() {
+ // threadpool_destroy(&core->threadpool);
+ input_system_shutdown(&g_core.input);
+ renderer_shutdown(&g_core.renderer);
+}
+
+bool should_exit() {
+ return key_just_released(KEYCODE_ESCAPE) || glfwWindowShouldClose(g_core.renderer.window);
+}
- return c;
+void frame_begin() {
+ glfwPollEvents();
+ render_frame_begin(&g_core.renderer);
}
+void frame_draw() {}
+void frame_end() { render_frame_end(&g_core.renderer); }