diff options
author | chai <chaifix@163.com> | 2018-12-21 19:02:22 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-12-21 19:02:22 +0800 |
commit | 84a663cb70b057a5ce0c9ff1910bc2eb9c0ba653 (patch) | |
tree | 625d2a7804c6f29aac367098972f96a47fcb7ae3 /src/libjin-lua/modules/graphics/je_lua_graphics.cpp | |
parent | 90cd4ff40e647e4150638e69f80ac587ceff1631 (diff) |
+2d mesh
Diffstat (limited to 'src/libjin-lua/modules/graphics/je_lua_graphics.cpp')
-rw-r--r-- | src/libjin-lua/modules/graphics/je_lua_graphics.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libjin-lua/modules/graphics/je_lua_graphics.cpp b/src/libjin-lua/modules/graphics/je_lua_graphics.cpp index fba77d7..aeb1921 100644 --- a/src/libjin-lua/modules/graphics/je_lua_graphics.cpp +++ b/src/libjin-lua/modules/graphics/je_lua_graphics.cpp @@ -9,6 +9,7 @@ #include "je_lua_sprite.h" #include "je_lua_spritesheet.h" #include "je_lua_bitmap.h" +#include "je_lua_mesh.h" #include "je_lua_ttf.h" #include "je_lua_ttf_data.h" #include "je_lua_texture.h" @@ -398,6 +399,22 @@ namespace JinEngine sprite->render(x, y, sx, sy, r); } + LUA_IMPLEMENT void l_draw_mesh(lua_State* L) + { + if (!luax_istype(L, 1, Jin_Lua_Mesh)) + return; + LuaObject* obj= (LuaObject*)luax_toudata(L, 1); + Mesh* mesh = obj->getObject<Mesh>(); + int x = luax_optnumber(L, 2, 0); + int y = luax_optnumber(L, 3, 0); + float sx = luax_optnumber(L, 4, 1); + float sy = luax_optnumber(L, 5, 1); + float r = luax_optnumber(L, 6, 0); + float ox = luax_optnumber(L, 7, 0); + float oy = luax_optnumber(L, 8, 0); + mesh->render(x, y, sx, sy, r, ox, oy); + } + LUA_IMPLEMENT int l_draw(lua_State* L) { if (luax_istype(L, 1, Jin_Lua_Texture)) @@ -410,6 +427,8 @@ namespace JinEngine l_draw_page(L); else if (luax_istype(L, 1, Jin_Lua_Sprite)) l_draw_sprite(L); + else if (luax_istype(L, 1, Jin_Lua_Mesh)) + l_draw_mesh(L); else { luax_typerror(L, 1, "texture or canvas"); @@ -455,7 +474,9 @@ namespace JinEngine else { luax_typerror(L, 1, "texture or canvas"); + return 1; } + return 0; } /* print(string, x, y, lineheight, spacing) */ @@ -900,6 +921,12 @@ namespace JinEngine return 1; } + LUA_IMPLEMENT int l_newMesh(lua_State* L) + { + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Mesh, new Shared(new Mesh())); + return 1; + } + /* setFont(font) */ LUA_IMPLEMENT int l_setFont(lua_State* L) { @@ -981,6 +1008,7 @@ namespace JinEngine luaopen_Animation(L); luaopen_Animator(L); luaopen_ParticleSystem(L); + luaopen_Mesh(L); luaL_Reg methods[] = { /* window */ @@ -1006,6 +1034,7 @@ namespace JinEngine { "newAnimation", l_newAnimation }, { "newAnimator", l_newAnimator }, { "newParticleSystem", l_newParticleSystem }, + { "newMesh", l_newMesh }, /* render */ { "setClearColor", l_setClearColor }, { "clear", l_clear }, |