diff options
Diffstat (limited to 'src/lua/modules/graphics/je_lua_sprite.cpp')
-rw-r--r-- | src/lua/modules/graphics/je_lua_sprite.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lua/modules/graphics/je_lua_sprite.cpp b/src/lua/modules/graphics/je_lua_sprite.cpp index 511f877..ec5887c 100644 --- a/src/lua/modules/graphics/je_lua_sprite.cpp +++ b/src/lua/modules/graphics/je_lua_sprite.cpp @@ -1,8 +1,12 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" + #include "je_lua_sprite.h" +#include "je_lua_canvas.h" +#include "je_lua_texture.h" +#include "je_lua_shader.h" using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Shaders; @@ -11,18 +15,19 @@ namespace JinEngine { namespace Lua { + const char* Jin_Lua_Sprite = "Sprite"; typedef Shared<Sprite>& SharedSprite; LUA_IMPLEMENT inline SharedSprite checkSprite(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Sprite); return proxy->getShared<Sprite>(); } LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITE); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Sprite); p->release(); return 0; } @@ -89,7 +94,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setShader(lua_State* L) { SharedSprite sprite = checkSprite(L); - Proxy* proxy = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_SHADER); + Proxy* proxy = (Proxy*)luax_checktype(L, 2, Jin_Lua_Shader); Shader* shader = proxy->getObject<Shader>(); sprite->setShader(shader); sprite.setDependency((int)SpriteDependency::DEP_SHADER, &proxy->getShared<Shader>()); @@ -101,10 +106,10 @@ namespace JinEngine SharedSprite sprite = checkSprite(L); Graphic* graphic = nullptr; Proxy* p = nullptr; - if (luax_istype(L, 2, JIN_GRAPHICS_TEXTURE)) - p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_TEXTURE); - else if (luax_istype(L, 2, JIN_GRAPHICS_CANVAS)) - p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_CANVAS); + if (luax_istype(L, 2, Jin_Lua_Texture)) + p = (Proxy*)luax_checktype(L, 2, Jin_Lua_Texture); + else if (luax_istype(L, 2, Jin_Lua_Canvas)) + p = (Proxy*)luax_checktype(L, 2, Jin_Lua_Canvas); if (p != nullptr) { sprite->setGraphic(p->getObject<Graphic>()); @@ -214,7 +219,7 @@ namespace JinEngine { "getColor", l_getColor }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_SPRITE, methods); + luax_newtype(L, Jin_Lua_Sprite, methods); return 0; } |