diff options
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; } |