From a73494d8858d67fd6b69ad4440b2b6657c0c9a5d Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 18 Jun 2022 14:09:02 -0500 Subject: add all window hints --- src/gl/window.c | 37 +++++++++++- src/gl/window.test.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 199 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gl/window.c b/src/gl/window.c index 24f21be..03afd24 100644 --- a/src/gl/window.c +++ b/src/gl/window.c @@ -7,7 +7,42 @@ void create_glfw_window_hints_table(lua_State *L) { hs_create_table(L, - hs_str_int("resizable", GLFW_RESIZABLE) + /* window hints */ + hs_str_int("resizable", GLFW_RESIZABLE), + hs_str_int("visible", GLFW_VISIBLE), + hs_str_int("decorated", GLFW_DECORATED), + hs_str_int("focused", GLFW_FOCUSED), + hs_str_int("autoIconify", GLFW_AUTO_ICONIFY), + hs_str_int("floating", GLFW_FLOATING), + hs_str_int("maximized", GLFW_MAXIMIZED), + hs_str_int("centerCursor", GLFW_CENTER_CURSOR), + hs_str_int("transparentFramebuffer", GLFW_TRANSPARENT_FRAMEBUFFER), + hs_str_int("focusOnShow", GLFW_FOCUS_ON_SHOW), + hs_str_int("scaleToMonitor", GLFW_SCALE_TO_MONITOR), + + /* framebuffer hints */ + hs_str_int("redBits", GLFW_RED_BITS), + hs_str_int("greenBits", GLFW_GREEN_BITS), + hs_str_int("blueBits", GLFW_BLUE_BITS), + hs_str_int("alphaBits", GLFW_ALPHA_BITS), + hs_str_int("depthBits", GLFW_DEPTH_BITS), + hs_str_int("stereoscopic", GLFW_STEREO), + hs_str_int("samples", GLFW_SAMPLES), + hs_str_int("srgbCapable", GLFW_SRGB_CAPABLE), + hs_str_int("doubleBuffer", GLFW_DOUBLEBUFFER), + + /* monitor & context hints */ + hs_str_int("refreshRate", GLFW_REFRESH_RATE), + hs_str_int("clientApi", GLFW_CLIENT_API), + hs_str_int("contextCreationApi", GLFW_CONTEXT_CREATION_API), + hs_str_int("contextVersionMajor", GLFW_CONTEXT_VERSION_MAJOR), + hs_str_int("contextVersionMinor", GLFW_CONTEXT_VERSION_MINOR), + hs_str_int("forwardCompatible", GLFW_OPENGL_FORWARD_COMPAT), + hs_str_int("debugContext", GLFW_OPENGL_DEBUG_CONTEXT), + hs_str_int("profile", GLFW_OPENGL_PROFILE), + hs_str_int("contextRobustness", GLFW_CONTEXT_ROBUSTNESS), + hs_str_int("contextReleaseBehavior", GLFW_CONTEXT_RELEASE_BEHAVIOR), + hs_str_int("noError", GLFW_CONTEXT_NO_ERROR) ); } diff --git a/src/gl/window.test.c b/src/gl/window.test.c index 8ba8a58..6d5c844 100644 --- a/src/gl/window.test.c +++ b/src/gl/window.test.c @@ -112,12 +112,18 @@ void gl_init_fail_glfwInit() 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)); + lily_assert_msg(lua_isnumber(L, -1), LILY_LOCATION, "key %s is not a number", key); int n = lua_tointeger(L, -1); lua_pop(L, 1); return n; } +#define CHECK_VALUE(str, num) \ + do { \ + int value = get_int(L, 1, str); \ + lily_assert_int_equal(value, num); \ + } while(0) + void glfw_window_hints_table() { lua_State *L = luaL_newstate(); @@ -127,10 +133,166 @@ void glfw_window_hints_table() lily_assert_int_equal(lua_gettop(L), 1); lily_assert_true(lua_istable(L, -1)); + /* window hints */ lily_assert_int_equal( get_int(L, 1, "resizable"), GLFW_RESIZABLE ); + lily_assert_int_equal( + get_int(L, 1, "visible"), + GLFW_VISIBLE + ); + + lily_assert_int_equal( + get_int(L, 1, "decorated"), + GLFW_DECORATED + ); + + lily_assert_int_equal( + get_int(L, 1, "focused"), + GLFW_FOCUSED + ); + + lily_assert_int_equal( + get_int(L, 1, "autoIconify"), + GLFW_AUTO_ICONIFY + ); + + lily_assert_int_equal( + get_int(L, 1, "floating"), + GLFW_FLOATING + ); + + lily_assert_int_equal( + get_int(L, 1, "maximized"), + GLFW_MAXIMIZED + ); + + lily_assert_int_equal( + get_int(L, 1, "centerCursor"), + GLFW_CENTER_CURSOR + ); + + lily_assert_int_equal( + get_int(L, 1, "transparentFramebuffer"), + GLFW_TRANSPARENT_FRAMEBUFFER + ); + + lily_assert_int_equal( + get_int(L, 1, "focusOnShow"), + GLFW_FOCUS_ON_SHOW + ); + + lily_assert_int_equal( + get_int(L, 1, "scaleToMonitor"), + GLFW_SCALE_TO_MONITOR + ); + + + /* framebuffer hints */ + /* (don't expose accumulation or auxiliary buffer hints) */ + lily_assert_int_equal( + get_int(L, 1, "redBits"), + GLFW_RED_BITS + ); + + lily_assert_int_equal( + get_int(L, 1, "greenBits"), + GLFW_GREEN_BITS + ); + + lily_assert_int_equal( + get_int(L, 1, "blueBits"), + GLFW_BLUE_BITS + ); + + lily_assert_int_equal( + get_int(L, 1, "alphaBits"), + GLFW_ALPHA_BITS + ); + + lily_assert_int_equal( + get_int(L, 1, "depthBits"), + GLFW_DEPTH_BITS + ); + + lily_assert_int_equal( + get_int(L, 1, "stereoscopic"), + GLFW_STEREO + ); + + lily_assert_int_equal( + get_int(L, 1, "samples"), + GLFW_SAMPLES + ); + + lily_assert_int_equal( + get_int(L, 1, "srgbCapable"), + GLFW_SRGB_CAPABLE + ); + + lily_assert_int_equal( + get_int(L, 1, "doubleBuffer"), + GLFW_DOUBLEBUFFER + ); + + + /* monitor & context hints */ + lily_assert_int_equal( + get_int(L, 1, "refreshRate"), + GLFW_REFRESH_RATE + ); + + lily_assert_int_equal( + get_int(L, 1, "clientApi"), + GLFW_CLIENT_API + ); + + lily_assert_int_equal( + get_int(L, 1, "contextCreationApi"), + GLFW_CONTEXT_CREATION_API + ); + + lily_assert_int_equal( + get_int(L, 1, "contextVersionMajor"), + GLFW_CONTEXT_VERSION_MAJOR + ); + + lily_assert_int_equal( + get_int(L, 1, "contextVersionMinor"), + GLFW_CONTEXT_VERSION_MINOR + ); + + lily_assert_int_equal( + get_int(L, 1, "forwardCompatible"), + GLFW_OPENGL_FORWARD_COMPAT + ); + + lily_assert_int_equal( + get_int(L, 1, "debugContext"), + GLFW_OPENGL_DEBUG_CONTEXT + ); + + lily_assert_int_equal( + get_int(L, 1, "profile"), + GLFW_OPENGL_PROFILE + ); + + lily_assert_int_equal( + get_int(L, 1, "contextRobustness"), + GLFW_CONTEXT_ROBUSTNESS + ); + + lily_assert_int_equal( + get_int(L, 1, "contextReleaseBehavior"), + GLFW_CONTEXT_RELEASE_BEHAVIOR + ); + + lily_assert_int_equal( + get_int(L, 1, "noError"), + GLFW_CONTEXT_NO_ERROR + ); + lua_close(L); } -- cgit v1.2.1