Slightly improved error messages when love.graphics.newShader fails

This commit is contained in:
Alex Szpakowski
2013-03-16 12:49:46 -03:00
parent f9d687cb65
commit e8c6a3f77c
+12 -2
View File
@@ -505,8 +505,6 @@ int w_newShader(lua_State *L)
if (!Shader::isSupported())
return luaL_error(L, "Sorry, your graphics card does not support shaders.");
try
{
// clamp stack to 2 elements
lua_settop(L, 2);
@@ -535,6 +533,18 @@ int w_newShader(lua_State *L)
sources[Shader::TYPE_FRAGMENT] = fragcode;
}
if (sources.empty())
{
// Original args had source code, but effectCodeToGLSL couldn't translate it
for (int i = 1; i <= 2; i++)
{
if (lua_isstring(L, i))
return luaL_argerror(L, i, "invalid or incomplete shader code");
}
}
try
{
Shader *shader = instance->newShader(sources);
luax_newtype(L, "Shader", GRAPHICS_SHADER_T, (void *)shader);
}