diff options
Diffstat (limited to 'src/lua5')
-rw-r--r-- | src/lua5/cdluagl5.c | 53 | ||||
-rw-r--r-- | src/lua5/cdluagl5.def | 3 |
2 files changed, 56 insertions, 0 deletions
diff --git a/src/lua5/cdluagl5.c b/src/lua5/cdluagl5.c new file mode 100644 index 0000000..ad81730 --- /dev/null +++ b/src/lua5/cdluagl5.c @@ -0,0 +1,53 @@ +/** \file + * \brief OpenGL Canvas Lua 5 Binding + * + * See Copyright Notice in cd.h + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "cd.h" +#include "cdgl.h" + +#include <lua.h> +#include <lauxlib.h> + +#include "cdlua.h" +#include "cdluagl.h" +#include "cdlua5_private.h" + + +static void *cdgl_checkdata(lua_State *L, int param) +{ + return (void *)luaL_checkstring(L, param); +} + +static cdluaContext cdluaglctx = +{ + 0, + "GL", + cdContextGL, + cdgl_checkdata, + NULL, + 0 +}; + +int cdluagl_open (lua_State *L) +{ + cdluaLuaState* cdL = cdlua_getstate(L); + lua_pushliteral(L, "cd"); +#if LUA_VERSION_NUM > 501 + lua_pushglobaltable(L); +#else + lua_gettable(L, LUA_GLOBALSINDEX); /* leave "cd" table at the top of the stack */ +#endif + cdlua_addcontext(L, cdL, &cdluaglctx); + return 1; +} + +int luaopen_cdluagl(lua_State* L) +{ + return cdluagl_open(L); +} + diff --git a/src/lua5/cdluagl5.def b/src/lua5/cdluagl5.def new file mode 100644 index 0000000..80e1e2d --- /dev/null +++ b/src/lua5/cdluagl5.def @@ -0,0 +1,3 @@ +EXPORTS + cdluagl_open + luaopen_cdluagl |