From 85ada97786f2ca4f934b75bdc1391db7c6d12275 Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Wed, 7 Aug 2019 22:31:17 +0200 Subject: [PATCH] ~ Fixed shaders not compiling properly when define values were used from the JSON, this should solve some backgrounds displaying a black background and nothing else Signed-off-by: Alexis Maiquez --- wallpaperengine/shaders/compiler.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/wallpaperengine/shaders/compiler.cpp b/wallpaperengine/shaders/compiler.cpp index 19d841f..ecab44c 100644 --- a/wallpaperengine/shaders/compiler.cpp +++ b/wallpaperengine/shaders/compiler.cpp @@ -44,7 +44,14 @@ namespace wp "#define ddx dFdx\n" "#define ddy(x) dFdy(-(x))\n" "#define GLSL 1\n\n"; - // TODO: Parse COMBO options from shaders and set at least default values + + std::map::const_iterator cur = this->m_combos->begin (); + std::map::const_iterator end = this->m_combos->end (); + + for (; cur != end; cur ++) + { + this->m_content += "#define " + (*cur).first + " " + std::to_string ((*cur).second) + "\n"; + } } else { @@ -464,6 +471,8 @@ namespace wp // check the combos std::map::const_iterator entry = this->m_combos->find ((*combo).get ()); + // if the combo was not found in the predefined values this means that the default value in the JSON data can be used + // so only define the ones that are not already defined if (entry == this->m_combos->end ()) { // if no combo is defined just load the default settings @@ -484,10 +493,6 @@ namespace wp wp::irrlicht::device->getLogger ()->log ("Cannot parse combo information, unknown type", irr::ELL_ERROR); } } - else - { - this->m_compiledContent += "#define " + (*combo).get () + " " + std::to_string ((*entry).second); - } } void compiler::parseParameterConfiguration (const std::string& type, const std::string& name, const std::string& content)