diff options
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 |