From 0d098410b3ffbf25376aa49a32d9ab2cd1bd7f57 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 27 Feb 2020 20:20:02 -0800 Subject: [PATCH] Shader:send doesn't error on unknown uniform; Instead it returns a boolean indicating if the send worked. --- src/api/l_graphics_shader.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/l_graphics_shader.c b/src/api/l_graphics_shader.c index 6599dcdf..ca8fd128 100644 --- a/src/api/l_graphics_shader.c +++ b/src/api/l_graphics_shader.c @@ -208,7 +208,10 @@ static int l_lovrShaderSend(lua_State* L) { Shader* shader = luax_checktype(L, 1, Shader); const char* name = luaL_checkstring(L, 2); const Uniform* uniform = lovrShaderGetUniform(shader, name); - lovrAssert(uniform, "Unknown shader variable '%s'", name); + if (!uniform) { + lua_pushboolean(L, false); + return 1; + } if (tempData.size < uniform->size) { tempData.size = uniform->size; @@ -223,7 +226,8 @@ static int l_lovrShaderSend(lua_State* L) { case UNIFORM_SAMPLER: lovrShaderSetTextures(shader, uniform->name, tempData.data, 0, uniform->count); break; case UNIFORM_IMAGE: lovrShaderSetImages(shader, uniform->name, tempData.data, 0, uniform->count); break; } - return 0; + lua_pushboolean(L, true); + return 1; } static int l_lovrShaderSendBlock(lua_State* L) {