diff options
author | sanine-a <sanine.not@pm.me> | 2020-10-24 21:35:14 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2020-10-24 21:35:14 -0500 |
commit | 41ac253f743e464194587c3ecc0f2547c95d924d (patch) | |
tree | 3a922066ecdf24bc5c33e200585cd70ecf4e080a /src/honey.c | |
parent | 27292f0d9ed90340792d4d065fefd2e4e248e4bd (diff) |
add window module and fullscreen toggle
Diffstat (limited to 'src/honey.c')
-rw-r--r-- | src/honey.c | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/src/honey.c b/src/honey.c index 0bd5b25..cfc5bc7 100644 --- a/src/honey.c +++ b/src/honey.c @@ -55,45 +55,24 @@ bool honey_parse_options(honey_options* options, int argc, char** argv) /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -bool honey_setup(lua_State** L, honey_window* window) +bool honey_setup(lua_State** L) { - /* set up glfw */ - glfwInit(); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - - *window = glfwCreateWindow(640, 480, "honey", NULL, NULL); - if (*window == NULL) { - fprintf(stderr, "[honey] ERROR: failed to create window!\n"); - glfwTerminate(); - return false; - } - - glfwMakeContextCurrent(*window); - - if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) { - fprintf(stderr, "[honey] ERROR: failed to initialize GLAD!\n"); - glfwTerminate(); - return false; - } - - honey_setup_keyboard(); - glfwSetKeyCallback(*window, default_honey_keyboard_callback); - - // Enable blending - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - /* set up lua and honey lua bindings */ *L = luaL_newstate(); luaL_openlibs(*L); - glfwSetWindowUserPointer(*window, *L); lua_createtable(*L, 0, 1); + if (!honey_setup_window(*L)) + return false; + + lua_getfield(*L, -1, "internal"); + honey_window_information* info = lua_touserdata(*L, -1); + lua_pop(*L, 1); + lua_setfield(*L, -2, "window"); + honey_setup_input(*L); + glfwSetKeyCallback(info->window, default_honey_keyboard_callback); lua_setfield(*L, -2, "input"); lua_setglobal(*L, "honey"); |