From 862763a88f6b4a6cb6c034287c509a91776adf8b Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 2 Sep 2018 00:48:21 +0800 Subject: *update --- src/lua/modules/graphics/graphics.cpp | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/lua/modules/graphics/graphics.cpp') diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp index 9c1d404..98a4fef 100644 --- a/src/lua/modules/graphics/graphics.cpp +++ b/src/lua/modules/graphics/graphics.cpp @@ -12,7 +12,7 @@ namespace lua using jin::filesystem::Filesystem; using jin::filesystem::Buffer; - typedef Texture Image; + typedef Texture Texture; static struct { @@ -70,21 +70,21 @@ namespace lua return 1; } - static int l_newImage(lua_State* L) + static int l_newTexture(lua_State* L) { Filesystem* fs = Filesystem::get(); const char* f = luax_checkstring(L, 1); if (!fs->exists(f)) { - printf("Error: no such image %s\n", f); + printf("Error: no such texture %s\n", f); exit(1); } Buffer b; fs->read(f, &b); - Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_IMAGE, sizeof(Proxy)); - Image* img = Image::createTexture(b.data, b.size); - proxy->bind(new Ref(img, JIN_GRAPHICS_IMAGE)); + Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_TEXTURE, sizeof(Proxy)); + Texture* img = Texture::createTexture(b.data, b.size); + proxy->bind(new Ref(img, JIN_GRAPHICS_TEXTURE)); return 1; } @@ -158,10 +158,10 @@ namespace lua float sx = luax_optnumber(L, 4, 1); float sy = luax_optnumber(L, 5, 1); float r = luax_optnumber(L, 6, 0); - if (luax_istype(L, 1, JIN_GRAPHICS_IMAGE)) + if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) { Proxy* proxy = (Proxy*)luax_toudata(L, 1); - Ref& tex = proxy->getRef(); + Ref& tex = proxy->getRef(); tex->draw(x, y, sx, sy, r); } else if (luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) @@ -173,7 +173,7 @@ namespace lua else { /* wrong type */ - luax_typerror(L, 1, "image or canvas"); + luax_typerror(L, 1, "texture or canvas"); } return 0; } @@ -198,7 +198,7 @@ namespace lua return 0; } - static int l_getColor(lua_State * L) + static int l_palette(lua_State * L) { luax_pushnumber(L, context.curRenderColor.rgba.r); luax_pushnumber(L, context.curRenderColor.rgba.g); @@ -267,7 +267,7 @@ namespace lua else return RENDER_MODE::NONE; } - static int l_drawpoint(lua_State* L) + static int l_point(lua_State* L) { int x = luax_checknumber(L, 1); int y = luax_checknumber(L, 2); @@ -276,7 +276,7 @@ namespace lua return 0; } - static int l_drawLine(lua_State* L) + static int l_line(lua_State* L) { int x1 = luax_checknumber(L, 1); int y1 = luax_checknumber(L, 2); @@ -287,7 +287,7 @@ namespace lua return 0; } - static int l_drawRect(lua_State* L) + static int l_rect(lua_State* L) { const char* modestr = luax_checkstring(L, 1); RENDER_MODE mode = strtomode(modestr); @@ -308,7 +308,7 @@ namespace lua return 0; } - static int l_drawCircle(lua_State* L) + static int l_circle(lua_State* L) { const char* modestr = luax_checkstring(L, 1); RENDER_MODE mode = strtomode(modestr); @@ -328,7 +328,7 @@ namespace lua return 0; } - static int l_drawTriangle(lua_State* L) + static int l_triangle(lua_State* L) { const char* modestr = luax_checkstring(L, 1); RENDER_MODE mode = strtomode(modestr); @@ -354,7 +354,7 @@ namespace lua return 0; } - static int l_drawPolygon(lua_State* L) + static int l_polygon(lua_State* L) { const char* modestr = luax_checkstring(L, 1); int n = luax_checknumber(L, 2); @@ -410,7 +410,7 @@ namespace lua return 1; } - static int l_study(lua_State* L) + static int l_setFont(lua_State* L) { int n = luax_gettop(L); if (n == 0) @@ -466,7 +466,7 @@ namespace lua { "getSize", l_getSize }, { "getWidth", l_getWidth }, { "getHeight", l_getHeight }, - { "newImage", l_newImage }, + { "newTexture", l_newTexture }, { "newShader", l_newShader }, { "newCanvas", l_newCanvas }, { "newFont", l_newFont }, @@ -476,24 +476,24 @@ namespace lua { "clear", l_clear }, { "draw", l_draw }, { "setColor", l_setColor }, - { "palette", l_getColor }, + { "palette", l_palette }, { "present", l_present }, - { "setFont", l_study }, + { "setFont", l_setFont }, { "bindCanvas", l_bindCanvas }, { "unbindCanvas", l_unbindCanvas }, { "useShader", l_useShader }, { "unuseShader", l_unuseShader }, - { "point", l_drawpoint }, - { "line", l_drawLine }, - { "rect", l_drawRect }, - { "circle", l_drawCircle }, - { "triangle", l_drawTriangle }, - { "polygon", l_drawPolygon }, + { "point", l_point }, + { "line", l_line }, + { "rect", l_rect }, + { "circle", l_circle }, + { "triangle", l_triangle }, + { "polygon", l_polygon }, { "destroy", l_destroy }, { 0, 0 } }; - extern int luaopen_Image(lua_State* L); + extern int luaopen_Texture(lua_State* L); extern int luaopen_Font(lua_State* L); extern int luaopen_Canvas(lua_State* L); extern int luaopen_JSL(lua_State* L); @@ -501,7 +501,7 @@ namespace lua int luaopen_graphics(lua_State* L) { // register types - luaopen_Image(L); + luaopen_Texture(L); luaopen_Canvas(L); luaopen_Font(L); luaopen_JSL(L); -- cgit v1.1-26-g67d0