diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-17 16:49:11 +1100 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-17 16:49:11 +1100 |
commit | 3e1aea0243f54e0b68baa3b19ac19f3d965484e0 (patch) | |
tree | 9f6e6d691be59ed328ffd716a0f56a2e33dbdf3d /src/core.c | |
parent | 16afbddeada7161e931dc261d3404bb5bbc1743d (diff) |
start on metal backend
Diffstat (limited to 'src/core.c')
-rw-r--r-- | src/core.c | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -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 |