diff options
Diffstat (limited to 'src/libjin-lua/modules/graphics/l_mesh.cpp')
-rw-r--r-- | src/libjin-lua/modules/graphics/l_mesh.cpp | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/src/libjin-lua/modules/graphics/l_mesh.cpp b/src/libjin-lua/modules/graphics/l_mesh.cpp index 73e0024..8e7581c 100644 --- a/src/libjin-lua/modules/graphics/l_mesh.cpp +++ b/src/libjin-lua/modules/graphics/l_mesh.cpp @@ -9,79 +9,79 @@ using namespace JinEngine::Graphics; namespace JinEngine { - namespace Lua - { + namespace Lua + { - const char* Jin_Lua_Mesh = "Mesh"; + const char* Jin_Lua_Mesh = "Mesh"; - LUA_IMPLEMENT inline Mesh* checkMesh(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - return luaObj->getObject<Mesh>(); - } + LUA_IMPLEMENT inline Mesh* checkMesh(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); + return luaObj->getObject<Mesh>(); + } - LUA_IMPLEMENT int l_getBound(lua_State* L) - { - Mesh* mesh = checkMesh(L); - BBox bbox = mesh->getBound(); - luax_pushnumber(L, bbox.l); - luax_pushnumber(L, bbox.r); - luax_pushnumber(L, bbox.t); - luax_pushnumber(L, bbox.b); - return 4; - } + LUA_IMPLEMENT int l_getBound(lua_State* L) + { + Mesh* mesh = checkMesh(L); + BBox bbox = mesh->getBound(); + luax_pushnumber(L, bbox.l); + luax_pushnumber(L, bbox.r); + luax_pushnumber(L, bbox.t); + luax_pushnumber(L, bbox.b); + return 4; + } - LUA_IMPLEMENT int l_setGraphic(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - Mesh* mesh = luaObj->getObject<Mesh>(); - luaObj->removeDependency((int)MeshDependency::DEP_GRAPHIC); - LuaObject* obj = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Texture); - mesh->setGraphic(obj->getObject<Texture>()); - luaObj->setDependency((int)MeshDependency::DEP_GRAPHIC, obj); - return 0; - } + LUA_IMPLEMENT int l_setGraphic(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); + Mesh* mesh = luaObj->getObject<Mesh>(); + luaObj->removeDependency((int)MeshDependency::DEP_GRAPHIC); + LuaObject* obj = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Texture); + mesh->setGraphic(obj->getObject<Texture>()); + luaObj->setDependency((int)MeshDependency::DEP_GRAPHIC, obj); + return 0; + } - // x, y, u, v, color_table - LUA_IMPLEMENT int l_pushVertex(lua_State* L) - { - Mesh* mesh = checkMesh(L); - float x = luax_checknumber(L, 2); - float y = luax_checknumber(L, 3); - float u = luax_checknumber(L, 4); - float v = luax_checknumber(L, 5); - if (!luax_istable(L, 6)) - { - luax_typerror(L, 6, "color table"); - return 1; - } - Color c; - c.r = luax_rawgetnumberthenpop(L, -1, 1); - c.g = luax_rawgetnumberthenpop(L, -1, 2); - c.b = luax_rawgetnumberthenpop(L, -1, 3); - c.a = luax_rawgetnumberthenpop(L, -1, 4); - mesh->pushVertex(x, y, u, v, c); - return 0; - } + // x, y, u, v, color_table + LUA_IMPLEMENT int l_pushVertex(lua_State* L) + { + Mesh* mesh = checkMesh(L); + float x = luax_checknumber(L, 2); + float y = luax_checknumber(L, 3); + float u = luax_checknumber(L, 4); + float v = luax_checknumber(L, 5); + if (!luax_istable(L, 6)) + { + luax_typerror(L, 6, "color table"); + return 1; + } + Color c; + c.r = luax_rawgetnumberthenpop(L, -1, 1); + c.g = luax_rawgetnumberthenpop(L, -1, 2); + c.b = luax_rawgetnumberthenpop(L, -1, 3); + c.a = luax_rawgetnumberthenpop(L, -1, 4); + mesh->pushVertex(x, y, u, v, c); + return 0; + } - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - luaObj->release(); - return 0; - } + LUA_IMPLEMENT int l_gc(lua_State* L) + { + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); + luaObj->release(); + return 0; + } - LUA_EXPORT void luaopen_Mesh(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "getBound", l_getBound }, - { "setGraphic", l_setGraphic }, - { "pushVertex", l_pushVertex }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Mesh, methods); - } + LUA_EXPORT void luaopen_Mesh(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "getBound", l_getBound }, + { "setGraphic", l_setGraphic }, + { "pushVertex", l_pushVertex }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Mesh, methods); + } - } // namespace Lua + } // namespace Lua } // namespace JinEngine
\ No newline at end of file |