diff options
author | chai <chaifix@163.com> | 2018-12-20 18:34:50 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-12-20 18:34:50 +0800 |
commit | ee8ef0433e36bf354a717bd4af679a0a5af2e6be (patch) | |
tree | 2fc748510200f8bc24928d1938300eecc0604deb /src/lua/modules/graphics/je_lua_shader.cpp | |
parent | 7ae40127f15f8f2cb963a7efeb018f7887ebc1ea (diff) |
*修改文件结构
Diffstat (limited to 'src/lua/modules/graphics/je_lua_shader.cpp')
-rw-r--r-- | src/lua/modules/graphics/je_lua_shader.cpp | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp deleted file mode 100644 index 9505444..0000000 --- a/src/lua/modules/graphics/je_lua_shader.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" - -#include "je_lua_shader.h" -#include "je_lua_canvas.h" -#include "je_lua_texture.h" - -using namespace JinEngine::Graphics; -using namespace JinEngine::Graphics::Shaders; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Shader = "Shader"; - - static inline Shader* checkShader(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); - return luaObj->getObject<Shader>(); - } - - /** - * jsl:sendNumber("variable", 0.1) - */ - LUA_IMPLEMENT int l_sendNumber(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - float number = luax_checknumber(L, 3); - shader->sendFloat(variable, number); - return 0; - } - - LUA_IMPLEMENT int l_sendTexture(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Texture); - shader->sendTexture(variable, luaObj->getObject<Texture>()); - return 0; - } - - LUA_IMPLEMENT int l_sendCanvas(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Canvas); - shader->sendCanvas(variable, luaObj->getObject<Canvas>()); - return 0; - } - - LUA_IMPLEMENT int l_sendVec2(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - float x = luax_rawgetnumber(L, 3, 1); - float y = luax_rawgetnumber(L, 3, 2); - shader->sendVec2(variable, x, y); - return 0; - } - - LUA_IMPLEMENT int l_sendVec3(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - float x = luax_rawgetnumber(L, 3, 1); - float y = luax_rawgetnumber(L, 3, 2); - float z = luax_rawgetnumber(L, 3, 3); - shader->sendVec3(variable, x, y, z); - return 0; - } - - LUA_IMPLEMENT int l_sendVec4(lua_State* L) - { - Shader* shader = checkShader(L); - const char* variable = luax_checkstring(L, 2); - if (!luax_istable(L, 3)) - { - luax_typerror(L, 3, "table"); - return 1; - } - float x = luax_rawgetnumber(L, 3, 1); - float y = luax_rawgetnumber(L, 3, 2); - float z = luax_rawgetnumber(L, 3, 3); - float w = luax_rawgetnumber(L, 3, 4); - shader->sendVec4(variable, x, y, z, w); - return 0; - } - - LUA_IMPLEMENT int l_sendColor(lua_State* L) - { - return l_sendVec4(L); - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Shader(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "sendNumber", l_sendNumber }, - { "sendTexture", l_sendTexture }, - { "sendCanvas", l_sendCanvas }, - { "sendVec2", l_sendVec2 }, - { "sendVec3", l_sendVec3 }, - { "sendVec4", l_sendVec4 }, - { "sendColor", l_sendColor }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Shader, methods); - } - - } // namespace Lua -} // namespace JinEngine
\ No newline at end of file |