From 51c7235d4e0a2df109dd5050328a0ad4a1878ae4 Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 10 Mar 2023 02:05:18 -0600 Subject: refactor: move glfw functions into separate table --- src/glfw/init.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/glfw/init.c (limited to 'src/glfw/init.c') diff --git a/src/glfw/init.c b/src/glfw/init.c new file mode 100644 index 0000000..6d91d28 --- /dev/null +++ b/src/glfw/init.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include "setup.h" + + +int glfwInit_bind(lua_State *L) +{ + int bind_result = glfwInit(); + lua_pushinteger(L, bind_result); + return 1; +} + + +int glfwTerminate_bind(lua_State *L) +{ + glfwTerminate(); + return 0; +} + + +int glfwInitHint_bind(lua_State *L) +{ + int hint = luaL_checkinteger(L, 1); + int value = luaL_checkinteger(L, 2); + glfwInitHint(hint, value); + return 0; +} + + +int glfwGetVersion_bind(lua_State *L) +{ + int major, minor, rev; + glfwGetVersion(&major, &minor, &rev); + lua_pushinteger(L, major); + lua_pushinteger(L, minor); + lua_pushinteger(L, rev); + return 3; +} + + +int glfwGetVersionString_bind(lua_State *L) +{ + const char * bind_result = glfwGetVersionString(); + lua_pushstring(L, bind_result); + return 1; +} + + +int glfwGetError_bind(lua_State *L) +{ + const char * description; + int bind_result = glfwGetError(&description); + lua_pushinteger(L, bind_result); + lua_pushstring(L, description); + return 2; +} -- cgit v1.2.1