mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-13 21:02:34 +08:00
Small cleanup of pass initialization code
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
9bb0a40bc5
commit
30bb8d6d72
@ -782,42 +782,30 @@ void CPass::setupShaderVariables ()
|
||||
}
|
||||
|
||||
for (const auto& cur : this->m_vertShader->getParameters ())
|
||||
{
|
||||
if (this->m_uniforms.find (cur->getName ()) != this->m_uniforms.end ())
|
||||
continue;
|
||||
|
||||
if (cur->is <CShaderVariableFloat> ())
|
||||
this->addUniform (cur->getName (), const_cast <float*> (reinterpret_cast <const float*> (cur->as <CShaderVariableFloat> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableInteger> ())
|
||||
this->addUniform (cur->getName (), const_cast <int*> (reinterpret_cast <const int*> (cur->as <CShaderVariableInteger> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableVector2> ())
|
||||
this->addUniform (cur->getName (), const_cast <glm::vec2*> (reinterpret_cast <const glm::vec2*> (cur->as <CShaderVariableVector2> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableVector3> ())
|
||||
this->addUniform (cur->getName (), const_cast <glm::vec3*> (reinterpret_cast <const glm::vec3*> (cur->as <CShaderVariableVector3> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableVector4> ())
|
||||
this->addUniform (cur->getName (), const_cast <glm::vec4*> (reinterpret_cast <const glm::vec4*> (cur->as <CShaderVariableVector4> ()->getValue ())));
|
||||
}
|
||||
if (this->m_uniforms.find (cur->getName ()) == this->m_uniforms.end ())
|
||||
this->addUniform (cur);
|
||||
|
||||
for (const auto& cur : this->m_fragShader->getParameters ())
|
||||
{
|
||||
if (this->m_uniforms.find (cur->getName ()) != this->m_uniforms.end ())
|
||||
continue;
|
||||
if (this->m_uniforms.find (cur->getName ()) == this->m_uniforms.end ())
|
||||
this->addUniform (cur);
|
||||
|
||||
if (cur->is <CShaderVariableFloat> ())
|
||||
this->addUniform (cur->getName (), const_cast <float*> (reinterpret_cast <const float*> (cur->as <CShaderVariableFloat> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableInteger> ())
|
||||
this->addUniform (cur->getName (), const_cast <int*> (reinterpret_cast <const int*> (cur->as <CShaderVariableInteger> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableVector2> ())
|
||||
this->addUniform (cur->getName (), const_cast <glm::vec2*> (reinterpret_cast <const glm::vec2*> (cur->as <CShaderVariableVector2> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableVector3> ())
|
||||
this->addUniform (cur->getName (), const_cast <glm::vec3*> (reinterpret_cast <const glm::vec3*> (cur->as <CShaderVariableVector3> ()->getValue ())));
|
||||
else if (cur->is <CShaderVariableVector4> ())
|
||||
this->addUniform (cur->getName (), const_cast <glm::vec4*> (reinterpret_cast <const glm::vec4*> (cur->as <CShaderVariableVector4> ()->getValue ())));
|
||||
}
|
||||
}
|
||||
|
||||
// define some basic methods for the template
|
||||
/*template double Core::jsonFindDefault (nlohmann::json& data, const char *key, double defaultValue);*/
|
||||
void CPass::addUniform (CShaderVariable* value)
|
||||
{
|
||||
if (value->is <CShaderVariableFloat> ())
|
||||
this->addUniform (value->getName (), const_cast <float*> (reinterpret_cast <const float*> (value->as <CShaderVariableFloat> ()->getValue ())));
|
||||
else if (value->is <CShaderVariableInteger> ())
|
||||
this->addUniform (value->getName (), const_cast <int*> (reinterpret_cast <const int*> (value->as <CShaderVariableInteger> ()->getValue ())));
|
||||
else if (value->is <CShaderVariableVector2> ())
|
||||
this->addUniform (value->getName (), const_cast <glm::vec2*> (reinterpret_cast <const glm::vec2*> (value->as <CShaderVariableVector2> ()->getValue ())));
|
||||
else if (value->is <CShaderVariableVector3> ())
|
||||
this->addUniform (value->getName (), const_cast <glm::vec3*> (reinterpret_cast <const glm::vec3*> (value->as <CShaderVariableVector3> ()->getValue ())));
|
||||
else if (value->is <CShaderVariableVector4> ())
|
||||
this->addUniform (value->getName (), const_cast <glm::vec4*> (reinterpret_cast <const glm::vec4*> (value->as <CShaderVariableVector4> ()->getValue ())));
|
||||
}
|
||||
|
||||
void CPass::addUniform (const std::string& name, int value)
|
||||
{
|
||||
this->addUniform (name, UniformType::Integer, value);
|
||||
|
@ -89,6 +89,7 @@ namespace WallpaperEngine::Render::Objects::Effects
|
||||
void setupUniforms ();
|
||||
void setupAttributes ();
|
||||
void addAttribute (const std::string& name, GLint type, GLint elements, const GLuint* value);
|
||||
void addUniform (CShaderVariable* value);
|
||||
void addUniform (const std::string& name, int value);
|
||||
void addUniform (const std::string& name, double value);
|
||||
void addUniform (const std::string& name, float value);
|
||||
|
Loading…
Reference in New Issue
Block a user