Explorar o código

~ quick fix for shader compilation with nested includes, should fix #103

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez %!s(int64=4) %!d(string=hai) anos
pai
achega
cf2e31a606
Modificáronse 1 ficheiros con 14 adicións e 5 borrados
  1. 14 5
      src/WallpaperEngine/Render/Shaders/Compiler.cpp

+ 14 - 5
src/WallpaperEngine/Render/Shaders/Compiler.cpp

@@ -265,11 +265,20 @@ namespace WallpaperEngine::Render::Shaders
                     // extract value between quotes
                     filename = this->extractQuotedValue (it); BREAK_IF_ERROR
 
-                    // load the content to the includes contents and continue with the next one
-                    // try to find the file first
-                    this->m_includesContent += "// begin of included from file " + filename + "\r\n";
-                    this->m_includesContent += this->lookupShaderFile (filename);
-                    this->m_includesContent += "\r\n// end of included from file " + filename + "\r\n";
+                    if (this->m_content.find (" main(") == std::string::npos && this->m_content.find (" main (") == std::string::npos)
+                    {
+                        this->m_compiledContent += "// begin of include from file " + filename + "\r\n";
+                        this->m_compiledContent += this->lookupShaderFile (filename);
+                        this->m_compiledContent += "\r\n// end of included from file " + filename + "\r\n";
+                    }
+                    else
+                    {
+                        // load the content to the includes contents and continue with the next one
+                        // try to find the file first
+                        this->m_includesContent += "// begin of included from file " + filename + "\r\n";
+                        this->m_includesContent += this->lookupShaderFile (filename);
+                        this->m_includesContent += "\r\n// end of included from file " + filename + "\r\n";
+                    }
                 }
                 else
                 {