Shader:hasStage;

This commit is contained in:
bjorn
2021-05-25 23:28:38 -06:00
committed by bjorn
parent f6559ce49e
commit a1c79c45d8
3 changed files with 23 additions and 0 deletions
+5
View File
@@ -564,6 +564,11 @@ Shader::~Shader()
attachDefault(STANDARD_DEFAULT);
}
bool Shader::hasStage(ShaderStageType stage)
{
return stages[stage] != nullptr;
}
void Shader::attachDefault(StandardShader defaultType)
{
Shader *defaultshader = standardShaders[defaultType];
+5
View File
@@ -167,6 +167,11 @@ public:
Shader(ShaderStage *vertex, ShaderStage *pixel);
virtual ~Shader();
/**
* Check whether a Shader has a stage.
**/
bool hasStage(ShaderStageType stage);
/**
* Binds this Shader's program to be used when rendering.
**/
+13
View File
@@ -491,12 +491,25 @@ int w_Shader_hasUniform(lua_State *L)
return 1;
}
int w_Shader_hasStage(lua_State* L)
{
Shader *shader = luax_checkshader(L, 1);
ShaderStageType stage;
const char *str = luaL_checkstring(L, 2);
if (!ShaderStage::getConstant(str, stage))
return luax_enumerror(L, "shader stage", str);
luax_pushboolean(L, shader->hasStage(stage));
return 1;
}
static const luaL_Reg w_Shader_functions[] =
{
{ "getWarnings", w_Shader_getWarnings },
{ "send", w_Shader_send },
{ "sendColor", w_Shader_sendColors },
{ "hasUniform", w_Shader_hasUniform },
{ "hasStage", w_Shader_hasStage },
{ 0, 0 }
};