Explorar o código

fix: support shaders without textures (like flat), improves #184

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez %!s(int64=2) %!d(string=hai) anos
pai
achega
bd5e452d34

+ 8 - 1
src/WallpaperEngine/Core/Objects/CEffect.cpp

@@ -76,7 +76,14 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, CObject* ob
                             if (textureNumber == 0) {
                                 auto* image = object->as<CImage> ();
 
-                                texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ());
+                                auto passTextures = (*image->getMaterial ()->getPasses ().begin ())->getTextures ();
+
+                                if (passTextures.empty ()) {
+                                    // TODO: SET CHECKERBOARD TEXTURE AS DEFAULT IN THESE SITUATIONS
+                                    texture = "";
+                                } else {
+                                    texture = *passTextures.begin ();
+                                }
                             } else {
                                 texture = "";
                             }

+ 1 - 3
src/WallpaperEngine/Render/CWallpaper.cpp

@@ -257,12 +257,10 @@ CFBO* CWallpaper::createFBO (const std::string& name, ITexture::TextureFormat fo
     return fbo;
 }
 
-void CWallpaper::aliasFBO(const std::string& alias, CFBO* original)
-{
+void CWallpaper::aliasFBO (const std::string& alias, CFBO* original) {
     this->m_fbos.insert (std::make_pair (alias, original));
 }
 
-
 const std::map<std::string, CFBO*>& CWallpaper::getFBOs () const {
     return this->m_fbos;
 }

+ 1 - 1
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -519,7 +519,7 @@ void CPass::setupUniforms () {
     this->addUniform ("g_UserAlpha", this->m_material->getImage ()->getImage ()->getAlpha ());
     this->addUniform ("g_Alpha", this->m_material->getImage ()->getImage ()->getAlpha ());
     this->addUniform ("g_Color", this->m_material->getImage ()->getImage ()->getColor ());
-    this->addUniform ("g_Color4", glm::vec4(this->m_material->getImage ()->getImage ()->getColor (), 1));
+    this->addUniform ("g_Color4", glm::vec4 (this->m_material->getImage ()->getImage ()->getColor (), 1));
     // TODO: VALIDATE THAT G_COMPOSITECOLOR REALLY COMES FROM THIS ONE
     this->addUniform ("g_CompositeColor", this->m_material->getImage ()->getImage ()->getColor ());
     // add some external variables