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())
|
if (!Shader::isSupported())
|
||||||
return luaL_error(L, "Sorry, your graphics card does not support shaders.");
|
return luaL_error(L, "Sorry, your graphics card does not support shaders.");
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// clamp stack to 2 elements
|
// clamp stack to 2 elements
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
|
|
||||||
@@ -535,10 +533,22 @@ int w_newShader(lua_State *L)
|
|||||||
sources[Shader::TYPE_FRAGMENT] = fragcode;
|
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);
|
Shader *shader = instance->newShader(sources);
|
||||||
luax_newtype(L, "Shader", GRAPHICS_SHADER_T, (void *)shader);
|
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
|
// memory is freed in Graphics::newShader
|
||||||
luax_getfunction(L, "graphics", "_transformGLSLErrorMessages");
|
luax_getfunction(L, "graphics", "_transformGLSLErrorMessages");
|
||||||
|
|||||||
Reference in New Issue
Block a user