diff options
Diffstat (limited to 'src/lua/graphics/luaopen_JSL.cpp')
-rw-r--r-- | src/lua/graphics/luaopen_JSL.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/src/lua/graphics/luaopen_JSL.cpp b/src/lua/graphics/luaopen_JSL.cpp deleted file mode 100644 index d1d3bac..0000000 --- a/src/lua/graphics/luaopen_JSL.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "libs/luax/luax.h" -#include "render/jsl.h" -#include "../luaopen_types.h" -namespace jin -{ -namespace lua -{ - - using namespace render; - - static inline JSLProgram* checkJSLProgram(lua_State* L) - { - return (JSLProgram*)luax_checktype(L, 1, TYPE_JSL); - } - - static enum VARIABLE_TYPE - { - INVALID = 0, - NUMBER , - IMAGE , - TEXEL - }; - - static VARIABLE_TYPE strtotype(const char* str) - { - std::string s = std::string(str); - if (s == "number") return NUMBER; - else if (s == "Image") return IMAGE; - else if (s == "Texel") return TEXEL; - else return INVALID; - } - - /** - * Use send function send variables to JSL program. - */ - static int l_send(lua_State* L) - { - JSLProgram* jsl = checkJSLProgram(L); - // number Image Texel - const char* typestr = luax_checkstring(L, 2); - // variable name - const char* variable = luax_checkstring(L, 3); - if (typestr != nullptr) - { - int type = strtotype(typestr); - switch (type) - { - case NUMBER: - { - float number = luax_checknumber(L, 4); - jsl->sendFloat(variable, number); - break; - } - case IMAGE: - { - Image* img = (Image*)luax_checktype(L, 4, TYPE_IMAGE); - jsl->sendImage(variable, img); - break; - } - case TEXEL: - break; - } - } - return 1; - } - - static int l_gc(lua_State* L) - { - - return 0; - } - - static const luaL_Reg f[] = { - {"send", l_send}, - {"__gc", l_gc}, - {0, 0} - }; - - /** - * JSL program - */ - int luaopen_JSL(lua_State* L) - { - luax_newtype(L, TYPE_JSL, f); - return 0; - } -} -}
\ No newline at end of file |