summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gl/window.c8
-rw-r--r--src/gl/window.test.c29
2 files changed, 37 insertions, 0 deletions
diff --git a/src/gl/window.c b/src/gl/window.c
index 834d6ce..24f21be 100644
--- a/src/gl/window.c
+++ b/src/gl/window.c
@@ -1,8 +1,16 @@
#include "gl/glad/glad.h"
#include <GLFW/glfw3.h>
#include <lua.h>
+#include <honeysuckle.h>
+void create_glfw_window_hints_table(lua_State *L)
+{
+ hs_create_table(L,
+ hs_str_int("resizable", GLFW_RESIZABLE)
+ );
+}
+
int gl_init(lua_State *L)
{
if (glfwInit() != GLFW_TRUE) {
diff --git a/src/gl/window.test.c b/src/gl/window.test.c
index 1403221..8ba8a58 100644
--- a/src/gl/window.test.c
+++ b/src/gl/window.test.c
@@ -57,11 +57,13 @@ int mock_hs_throw_error(lua_State *L, const char *format_string, ...)
/* ~~~~~~~~ TESTS ~~~~~~~~ */
void gl_init_succeeds();
void gl_init_fail_glfwInit();
+void glfw_window_hints_table();
void suite_window()
{
lily_run_test(gl_init_succeeds);
lily_run_test(gl_init_fail_glfwInit);
+ lily_run_test(glfw_window_hints_table);
CLEAN_MOCK(mock_glfwInit);
}
@@ -105,3 +107,30 @@ void gl_init_fail_glfwInit()
lily_assert_string_equal((char*) fmt, "failed to initialize GLFW");
}
+
+
+int get_int(lua_State *L, int table_index, const char *key)
+{
+ lua_getfield(L, table_index, key);
+ lily_assert_true(lua_isnumber(L, -1));
+ int n = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+ return n;
+}
+
+void glfw_window_hints_table()
+{
+ lua_State *L = luaL_newstate();
+
+ lily_assert_int_equal(lua_gettop(L), 0);
+ create_glfw_window_hints_table(L);
+ lily_assert_int_equal(lua_gettop(L), 1);
+ lily_assert_true(lua_istable(L, -1));
+
+ lily_assert_int_equal(
+ get_int(L, 1, "resizable"),
+ GLFW_RESIZABLE
+ );
+
+ lua_close(L);
+}