From 899e70147ff7c866f131ba7bfb98193c4e68027f Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 19 Aug 2022 13:53:18 -0500 Subject: add shaders and basic drawing functions --- src/gl/window.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/gl/window.c') diff --git a/src/gl/window.c b/src/gl/window.c index 8434a5a..cb30d3f 100644 --- a/src/gl/window.c +++ b/src/gl/window.c @@ -6,8 +6,10 @@ int window_create(lua_State *L); int window_destroy(lua_State *L); +int window_make_context_current(lua_State *L); int window_should_close(lua_State *L); int window_poll_events(lua_State *L); +int window_swap_buffers(lua_State *L); void setup_window(lua_State *L, int honey_index) @@ -15,8 +17,10 @@ void setup_window(lua_State *L, int honey_index) hs_create_table(L, hs_str_cfunc("create", window_create), hs_str_cfunc("destroy", window_destroy), + hs_str_cfunc("makeContextCurrent", window_make_context_current), hs_str_cfunc("shouldClose", window_should_close), - hs_str_cfunc("pollEvents", window_poll_events) + hs_str_cfunc("pollEvents", window_poll_events), + hs_str_cfunc("swapBuffers", window_swap_buffers), ); lua_setfield(L, honey_index, "window"); } @@ -46,6 +50,16 @@ int window_destroy(lua_State *L) } +int window_make_context_current(lua_State *L) +{ + void *ptr; + hs_parse_args(L, hs_light(ptr)); + GLFWwindow *win = ptr; + glfwMakeContextCurrent(win); + return 0; +} + + int window_should_close(lua_State *L) { void *ptr; @@ -61,3 +75,13 @@ int window_poll_events(lua_State *L) glfwPollEvents(); return 0; } + + +int window_swap_buffers(lua_State *L) +{ + void *ptr; + hs_parse_args(L, hs_light(ptr)); + GLFWwindow *win = ptr; + glfwSwapBuffers(win); + return 0; +} -- cgit v1.2.1