فهرست منبع

+ Added handling for floating point precision qualifiers on type detection
+ Fixed textures not being detected properly on images that do not have any source

Signed-off-by: Alexis Maiquez <almamu@almamu.com>

Alexis Maiquez 4 سال پیش
والد
کامیت
342522cd1d
2فایلهای تغییر یافته به همراه24 افزوده شده و 5 حذف شده
  1. 18 5
      src/WallpaperEngine/Render/Objects/CImage.cpp
  2. 6 0
      src/WallpaperEngine/Render/Shaders/Compiler.cpp

+ 18 - 5
src/WallpaperEngine/Render/Objects/CImage.cpp

@@ -39,16 +39,29 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
         throw std::runtime_error ("Only centered images are supported for now!");
     }
 
-    std::string textureName = (*(*this->m_image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ());
+    // detect texture (if any)
+    auto textures = (*this->m_image->getMaterial ()->getPasses ().begin ())->getTextures ();
 
-    if (textureName.find ("_rt_") == 0)
+    if (textures.empty() == false)
     {
-        this->m_texture = this->getScene ()->findFBO (textureName);
+        std::string textureName = *textures.begin ();
+
+        if (textureName.find ("_rt_") == 0)
+        {
+            this->m_texture = this->getScene ()->findFBO (textureName);
+        }
+        else
+        {
+            // get the first texture on the first pass (this one represents the image assigned to this object)
+            this->m_texture = this->getScene ()->getContainer ()->readTexture (textureName);
+        }
     }
     else
     {
-        // get the first texture on the first pass (this one represents the image assigned to this object)
-        this->m_texture = this->getScene ()->getContainer ()->readTexture (textureName);
+        glm::vec2 realSize = size * glm::vec2 (scale);
+
+        // TODO: create a dummy texture of correct size, fbo constructors should be enough, but this should be properly handled
+        this->m_texture = new CFBO ("", ITexture::TextureFormat::ARGB8888, 1, realSize.x, realSize.y, realSize.x, realSize.y);
     }
 
     // register both FBOs into the scene

+ 6 - 0
src/WallpaperEngine/Render/Shaders/Compiler.cpp

@@ -106,6 +106,12 @@ namespace WallpaperEngine::Render::Shaders
 
     std::string Compiler::extractType (std::string::const_iterator& it)
     {
+        // first of all check for highp/mediump/lowp as these operators have to be ignored
+        this->peekString ("highp", it);
+        this->peekString ("mediump", it);
+        this->peekString ("lowp", it);
+        this->ignoreSpaces (it);
+
         auto cur = sTypes.begin ();
         auto end = sTypes.end ();