summaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/core.c b/src/core.c
index 0c3c5ea..080e806 100644
--- a/src/core.c
+++ b/src/core.c
@@ -4,12 +4,35 @@
NAMESPACED_LOGGER(core);
+core g_core = {0};
+
+// forward declares
+void key_callback(GLFWwindow* win, int key, int scancode, int action, int mods);
+
void core_bringup(const char* window_name, struct GLFWwindow* optional_window) {
- // INFO("Initiate Core bringup");
INFO("Initiate Core bringup");
INFO("Create GLFW window");
+ glfwInit();
+ GLFWwindow* glfw_window = glfwCreateWindow(800, 600, window_name, NULL, NULL);
+ g_core.window = glfw_window;
+
+ // This may move into a renderer struct
+ ral_backend_init(window_name, glfw_window);
+
+ glfwSetKeyCallback(glfw_window, key_callback);
+}
+void core_shutdown() {
+ ral_backend_shutdown();
+ glfwTerminate();
+}
+
+bool app_should_exit() {
+ return glfwWindowShouldClose(g_core.window) || g_core.should_exit;
}
-void core_shutdown() {}
-bool app_should_exit() { return false; }
+void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
+ if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) {
+ g_core.should_exit = true;
+ }
+} \ No newline at end of file