From c446e8186afa31c8d346383c0db8b8070fa563cd Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 4 Jan 2019 22:54:59 +0800 Subject: =?UTF-8?q?*=E7=BC=96=E8=AF=91jsl=20shader=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=E4=BD=BF=E7=94=A8error=20shader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/graphics/je_lua_graphics.cpp | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/libjin-lua/modules/graphics/je_lua_graphics.cpp') diff --git a/src/libjin-lua/modules/graphics/je_lua_graphics.cpp b/src/libjin-lua/modules/graphics/je_lua_graphics.cpp index a77f1ad..96577f5 100644 --- a/src/libjin-lua/modules/graphics/je_lua_graphics.cpp +++ b/src/libjin-lua/modules/graphics/je_lua_graphics.cpp @@ -197,14 +197,14 @@ namespace JinEngine } catch (Exception& e) { - error(L, "Failed to read image %s", f); + luax_errorf(L, "Failed to read image %s", f); luax_pushnil(L); return 1; } bitmap = new Bitmap(&b, b.size()); if (bitmap == nullptr) { - error(L, "Failed to decode image file %s", f); + luax_errorf(L, "Failed to decode image file %s", f); luax_pushnil(L); return 1; } @@ -232,13 +232,18 @@ namespace JinEngine return 1; } + // See embed graphics.lua. LUA_IMPLEMENT int l_newShader(lua_State* L) { const char* program = luax_checkstring(L, 1); - Shader* jsl = new Shader(program); - if (jsl == nullptr) + Shader* jsl = nullptr; + try { - error(L, "Failed to compile shader"); + jsl = new Shader(program); + } + catch (JinEngine::Exception& e) + { + //luax_errorf(L, "Failed to compile shader"); luax_pushnil(L); return 1; } @@ -246,22 +251,27 @@ namespace JinEngine return 1; } + // See embed graphics.lua LUA_IMPLEMENT int l_newShaderf(lua_State* L) { const char* path = luax_checkstring(L, 1); AssetDatabase* fs = AssetDatabase::get(); if (!fs->exists(path)) { - error(L, "No such shader file \"%s\"", path); + //luax_errorf(L, "No such shader file \"%s\"", path); luax_pushnil(L); return 1; } Buffer b; fs->read(path, b); - Shader* jsl = new Shader((char*)&b); - if (jsl == nullptr) + Shader* jsl = nullptr; + try + { + jsl = new Shader((char*)&b); + } + catch (JinEngine::Exception& e) { - error(L, "Failed to compile shader"); + //luax_errorf(L, "Failed to compile shader"); luax_pushnil(L); return 1; } @@ -705,7 +715,7 @@ namespace JinEngine AssetDatabase* fs = AssetDatabase::get(); if (!fs->exists(path)) { - error(L, "No such font \"%s\"", path); + luax_errorf(L, "No such font \"%s\"", path); luax_pushnil(L); return 1; } -- cgit v1.1-26-g67d0