summaryrefslogtreecommitdiff
path: root/src/glfw
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-10 02:33:42 -0600
committersanine <sanine.not@pm.me>2023-03-10 02:33:42 -0600
commitc2329b4c8258baa9429c77566c9def97d00e96d7 (patch)
tree029da1a4a2c5ac7bd7714ee70f195378f5c68c8e /src/glfw
parent51c7235d4e0a2df109dd5050328a0ad4a1878ae4 (diff)
demonstrate working glfw refactored bindings
Diffstat (limited to 'src/glfw')
-rw-r--r--src/glfw/setup.c11
-rw-r--r--src/glfw/setup.h1
-rw-r--r--src/glfw/window.c12
3 files changed, 21 insertions, 3 deletions
diff --git a/src/glfw/setup.c b/src/glfw/setup.c
index 0abab35..4ba49a4 100644
--- a/src/glfw/setup.c
+++ b/src/glfw/setup.c
@@ -1,5 +1,6 @@
#include <lua.h>
#include <lauxlib.h>
+#include <GLFW/glfw3.h>
#include "util/util.h"
#include "setup.h"
@@ -29,5 +30,15 @@ void setup_glfw(lua_State *L, int honey_tbl)
};
create_table(L, tbl);
+ int t = lua_gettop(L);
+
+ GLFWwindow ** window_null = create_window(L);
+ *window_null = NULL;
+ lua_setfield(L, t, "window_NULL");
+
+ GLFWmonitor ** monitor_null = create_monitor(L);
+ *monitor_null = NULL;
+ lua_setfield(L, t, "monitor_NULL");
+
lua_setfield(L, honey_tbl, "glfw");
}
diff --git a/src/glfw/setup.h b/src/glfw/setup.h
index 1b30728..4226c3b 100644
--- a/src/glfw/setup.h
+++ b/src/glfw/setup.h
@@ -29,6 +29,7 @@ struct h_glfw_window_data_t {
};
+GLFWwindow ** create_window(lua_State *L);
GLFWmonitor ** create_monitor(lua_State *L);
diff --git a/src/glfw/window.c b/src/glfw/window.c
index 1aafeb4..0199fb0 100644
--- a/src/glfw/window.c
+++ b/src/glfw/window.c
@@ -19,11 +19,18 @@ GLFWwindow ** create_window(lua_State *L)
luaL_getmetatable(L, glfw_window_tname);
lua_setmetatable(L, -2);
- /* configure window data struct */
d->data.L = L;
lua_pushvalue(L, self);
d->data.self_ref = luaL_ref(L, LUA_REGISTRYINDEX);
+ return window;
+}
+
+static void configure_window(GLFWwindow **window)
+{
+ struct window_data_t *d = (struct window_data_t *) window;
+
+ /* configure window data struct */
d->data.key_cb_ref = LUA_NOREF;
d->data.char_cb_ref = LUA_NOREF;
d->data.char_mods_cb_ref = LUA_NOREF;
@@ -43,8 +50,6 @@ GLFWwindow ** create_window(lua_State *L)
d->data.content_scale_cb_ref = LUA_NOREF;
glfwSetWindowUserPointer(*window, &(d->data));
-
- return window;
}
@@ -83,6 +88,7 @@ int glfwCreateWindow_bind(lua_State *L)
GLFWwindow ** window = create_window(L);
*window = glfwCreateWindow(width, height, title, *monitor, *share);
+ configure_window(window);
return 1;
}