static int Ltimer_cancel(lua_State *L) { lzn_Timer *obj = (lzn_Timer*)lbind_check(L, 1, &lbT_Timer); if (!obj->timer) return 0; lzn_unref(L, &obj->ref); zn_canceltimer(obj->timer); lbind_returnself(L); }
static int Lwin_fbsize(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); int width, height; glfwGetFramebufferSize(win, &width, &height); lua_pushinteger(L, width); lua_pushinteger(L, height); return 2; }
static int Lwin_cursorpos(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); double mx, my; glfwGetCursorPos(win, &mx, &my); lua_pushnumber(L, mx); lua_pushnumber(L, my); return 2; }
static int Ltimer_start(lua_State *L) { lzn_Timer *obj = (lzn_Timer*)lbind_check(L, 1, &lbT_Timer); lua_Integer delayms = luaL_optinteger(L, 2, 0); if (!obj->timer) return 0; if (delayms < 0) delayms = 0; obj->delayms = (unsigned)delayms; if (zn_starttimer(obj->timer, obj->delayms)) lzn_ref(L, 1, &obj->ref); lbind_returnself(L); }
static int Ltimer_new(lua_State *L) { zn_State *S = (zn_State*)lbind_check(L, 1, &lbT_State); lzn_Timer *obj; luaL_checktype(L, 2, LUA_TFUNCTION); obj = (lzn_Timer*)lbind_new(L, sizeof(lzn_Timer), &lbT_Timer); obj->timer = zn_newtimer(S, lzn_ontimer, obj); obj->L = L; obj->ontimer_ref = LUA_NOREF; obj->ref = LUA_NOREF; if (obj->timer != NULL) { lzn_ref(L, 2, &obj->ontimer_ref); return 1; } return 0; }
static int Lwin_key(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); int keycode = check_keycode(L, 2); lua_pushboolean(L, glfwGetKey(win, keycode) == GLFW_PRESS); return 1; }
static int Lwin_swapbuffers(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); glfwSwapBuffers(win); lbind_returnself(L); }
static int Lwin_makecurrent(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); glfwMakeContextCurrent(win); lbind_returnself(L); }
static int Lwin_shouldclose(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); lua_pushboolean(L, glfwWindowShouldClose(win)); return 1; }
static int Lwin_restore(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); glfwRestoreWindow(win); lbind_returnself(L); }
static int Lwin_iconify(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); glfwIconifyWindow(win); lbind_returnself(L); }
static int Lwin_show(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); glfwShowWindow(win); lbind_returnself(L); }