|
@@ -324,36 +324,12 @@ int w_Shader_send(lua_State *L)
|
|
|
return luaL_argerror(L, 3, "number, boolean, table, image, or canvas expected");
|
|
|
}
|
|
|
|
|
|
-int w_Shader_getUniformVariable(lua_State *L)
|
|
|
+int w_Shader_hasUniform(lua_State *L)
|
|
|
{
|
|
|
Shader *shader = luax_checkshader(L, 1);
|
|
|
const char *name = luaL_checkstring(L, 2);
|
|
|
-
|
|
|
- int components = 0;
|
|
|
- int arrayelements = 0;
|
|
|
- Shader::UniformType type = Shader::UNIFORM_UNKNOWN;
|
|
|
-
|
|
|
- type = shader->getUniformVariable(name, components, arrayelements);
|
|
|
-
|
|
|
- // Check if the variable exists (function will set components to 0 if not.)
|
|
|
- if (components > 0)
|
|
|
- {
|
|
|
- const char *tname = nullptr;
|
|
|
- if (!Shader::getConstant(type, tname))
|
|
|
- return luaL_error(L, "Unknown uniform variable type name.");
|
|
|
-
|
|
|
- lua_pushstring(L, tname);
|
|
|
- lua_pushinteger(L, components);
|
|
|
- lua_pushinteger(L, arrayelements);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- lua_pushnil(L);
|
|
|
- lua_pushnil(L);
|
|
|
- lua_pushnil(L);
|
|
|
- }
|
|
|
-
|
|
|
- return 3;
|
|
|
+ luax_pushboolean(L, shader->hasUniform(name));
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
static const luaL_Reg w_Shader_functions[] =
|
|
@@ -366,7 +342,7 @@ static const luaL_Reg w_Shader_functions[] =
|
|
|
{ "sendMatrix", w_Shader_sendMatrix },
|
|
|
{ "sendTexture", w_Shader_sendTexture },
|
|
|
{ "send", w_Shader_send },
|
|
|
- { "getUniformVariable", w_Shader_getUniformVariable },
|
|
|
+ { "hasUniform", w_Shader_hasUniform },
|
|
|
{ 0, 0 }
|
|
|
};
|
|
|
|