mirror of
https://github.com/love2d/love.git
synced 2026-08-21 13:09:56 +02:00
Slightly improved error messages when love.graphics.newShader fails
This commit is contained in:
@@ -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,10 +533,22 @@ 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);
|
||||
}
|
||||
catch(const love::Exception &e)
|
||||
catch (const love::Exception &e)
|
||||
{
|
||||
// memory is freed in Graphics::newShader
|
||||
luax_getfunction(L, "graphics", "_transformGLSLErrorMessages");
|
||||
|
||||
Reference in New Issue
Block a user