diff options
author | chai <chaifix@163.com> | 2018-08-12 19:52:54 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-12 19:52:54 +0800 |
commit | 7b34bd98bb00796febd5351b9d2e75fd2c247432 (patch) | |
tree | dd2da6fa01094f864d8deb358d7f9a8fe1b32b1c /src/lua/graphics/luaopen_graphics.cpp | |
parent | 5fe41eca99adf4bf0fb5832033a96f98b530d4f1 (diff) |
*update
Diffstat (limited to 'src/lua/graphics/luaopen_graphics.cpp')
-rw-r--r-- | src/lua/graphics/luaopen_graphics.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp index 2aa68e8..da91c51 100644 --- a/src/lua/graphics/luaopen_graphics.cpp +++ b/src/lua/graphics/luaopen_graphics.cpp @@ -77,9 +77,9 @@ namespace lua Buffer b; fs->read(f, &b); - Proxy* proxy = (Proxy*)luax_newinstance(L, TYPE_IMAGE, sizeof(Proxy)); + Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_IMAGE, sizeof(Proxy)); Texture* img = Texture::createTexture(b.data, b.size); - proxy->bind(img); + proxy->bind(img, JIN_GRAPHICS_IMAGE); return 1; } @@ -89,10 +89,10 @@ namespace lua */ static int l_newShader(lua_State* L) { - Proxy* proxy = (Proxy*)luax_newinstance(L, TYPE_JSL, sizeof(Proxy)); + Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_SHADER, sizeof(Proxy)); const char* program = luax_checkstring(L, 1); JSLProgram* jsl = JSLProgram::createJSLProgram(program); - proxy->bind(jsl); + proxy->bind(jsl, JIN_GRAPHICS_SHADER); return 1; } @@ -104,9 +104,9 @@ namespace lua { int w = luax_checknumber(L, 1); int h = luax_checknumber(L, 2); - Proxy* proxy = (Proxy*)luax_newinstance(L, TYPE_CANVAS, sizeof(Proxy)); + Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_CANVAS, sizeof(Proxy)); Canvas* cvs = Canvas::createCanvas(w, h); - proxy->bind(cvs); + proxy->bind(cvs, JIN_GRAPHICS_CANVAS); return 1; } @@ -145,13 +145,13 @@ 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, TYPE_IMAGE)) + if (luax_istype(L, 1, JIN_GRAPHICS_IMAGE)) { Proxy* proxy = (Proxy*)luax_toudata(L, 1); Texture* tex = (Texture*)proxy->object; tex->draw(x, y, sx, sy, r); } - else if (luax_istype(L, 1, TYPE_CANVAS)) + else if (luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) { Proxy* proxy = (Proxy*)luax_toudata(L, 1); Canvas* p = (Canvas*)proxy->object; @@ -204,7 +204,7 @@ namespace lua Canvas::unbind(); return 0; } - Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_CANVAS); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); Canvas* c = (Canvas*)proxy->object; c->bind(); return 0; @@ -223,7 +223,7 @@ namespace lua JSLProgram::unuse(); return 0; } - if (luax_istype(L, 1, TYPE_JSL)) + if (luax_istype(L, 1, JIN_GRAPHICS_SHADER)) { Proxy* proxy = (Proxy*)luax_toudata(L, 1); JSLProgram* jsl = (JSLProgram*)proxy->object; @@ -389,7 +389,7 @@ namespace lua static int l_newFont(lua_State* L) { - Font* font = (Font*)luax_newinstance(L, TYPE_FONT, sizeof(Font)); + Font* font = (Font*)luax_newinstance(L, JIN_GRAPHICS_FONT, sizeof(Font)); const char* path = luax_checkstring(L, 1); Filesystem* fs = Filesystem::get(); Buffer b = {}; @@ -422,7 +422,7 @@ namespace lua context.curFont = context.defaultFont; return 0; } - Font* font = (Font*)luax_checktype(L, 1, TYPE_FONT); + Font* font = (Font*)luax_checktype(L, 1, JIN_GRAPHICS_FONT); context.curFont = font; return 0; } |