aboutsummaryrefslogtreecommitdiff
path: root/src/libjin-lua/modules/graphics/je_lua_graphics.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-01-07 09:54:08 +0800
committerchai <chaifix@163.com>2019-01-07 09:54:08 +0800
commit2af7f2f5e3da8f6c236e7996781950e1bc6c1f9c (patch)
treef6a8a9618e146c93e4d4d964a6e13cd16f528693 /src/libjin-lua/modules/graphics/je_lua_graphics.cpp
parent909e544ed322b28a6f59febf3213e05068e9e93c (diff)
parentda056982e50bdd9cb9f944691cc88ca98b053b77 (diff)
Merge branch 'master' of warmcat.org:/home/git-repo/Jin
Diffstat (limited to 'src/libjin-lua/modules/graphics/je_lua_graphics.cpp')
-rw-r--r--src/libjin-lua/modules/graphics/je_lua_graphics.cpp30
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;
}