diff options
author | chai <chaifix@163.com> | 2019-01-04 22:54:59 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-04 22:54:59 +0800 |
commit | c446e8186afa31c8d346383c0db8b8070fa563cd (patch) | |
tree | a2a0e088c51f1ba251756aa5ab50b27dc8eeef39 /src/libjin-lua/modules/graphics/je_lua_graphics.cpp | |
parent | c42eb2529eead4b17c0c7f9da7ac9c41563a13fa (diff) |
*编译jsl shader失败时使用error shader
Diffstat (limited to 'src/libjin-lua/modules/graphics/je_lua_graphics.cpp')
-rw-r--r-- | src/libjin-lua/modules/graphics/je_lua_graphics.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
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; } |