Shader:send doesn't error on unknown uniform;

Instead it returns a boolean indicating if the send worked.
This commit is contained in:
bjorn 2020-02-27 20:20:02 -08:00
parent 90b605f012
commit 0d098410b3
1 changed files with 6 additions and 2 deletions

View File

@ -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) {