~ fix type extraction on shaders not working properly

+ added uint4 and mat4x3 types

Signed-off-by: Alexis Maiquez Murcia <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez Murcia 2021-09-04 21:49:48 +02:00
parent b152913d90
commit 30b4eb4cd4

View File

@ -111,7 +111,7 @@ namespace WallpaperEngine::Render::Shaders
while (cur != end) while (cur != end)
{ {
if (this->peekString (*cur, it) == true) if (this->peekString (*cur + " ", it) == true)
{ {
return *cur; return *cur;
} }
@ -247,7 +247,7 @@ namespace WallpaperEngine::Render::Shaders
} }
else if (*it == '#') else if (*it == '#')
{ {
if (this->peekString ("#include", it) == true) if (this->peekString ("#include ", it) == true)
{ {
std::string filename = ""; std::string filename = "";
@ -270,7 +270,7 @@ namespace WallpaperEngine::Render::Shaders
else if (*it == 'u') else if (*it == 'u')
{ {
// uniforms might have extra information for their values // uniforms might have extra information for their values
if (this->peekString ("uniform", it) == true) if (this->peekString ("uniform ", it) == true)
{ {
this->ignoreSpaces (it); this->ignoreSpaces (it);
std::string type = this->extractType (it); BREAK_IF_ERROR std::string type = this->extractType (it); BREAK_IF_ERROR
@ -308,52 +308,51 @@ namespace WallpaperEngine::Render::Shaders
this->ignoreSpaces (it); this->ignoreSpaces (it);
} }
}*/ }*/
// else if (*it == 'a') else if (*it == 'a')
// { {
// // find attribute definitions // find attribute definitions
// if (this->peekString ("attribute", it) == true) if (this->peekString ("attribute ", it) == true)
// { {
// this->ignoreSpaces (it); this->ignoreSpaces (it);
// std::string type = this->extractType (it); BREAK_IF_ERROR std::string type = this->extractType (it); BREAK_IF_ERROR
// this->ignoreSpaces (it); this->ignoreSpaces (it);
// std::string name = this->extractName (it); BREAK_IF_ERROR std::string name = this->extractName (it); BREAK_IF_ERROR
// this->ignoreSpaces (it); this->ignoreSpaces (it);
// std::string array = this->extractArray (it, false); BREAK_IF_ERROR std::string array = this->extractArray (it, false); BREAK_IF_ERROR
// this->ignoreSpaces (it); this->ignoreSpaces (it);
// this->expectSemicolon (it); BREAK_IF_ERROR this->expectSemicolon (it); BREAK_IF_ERROR
//
// this->m_compiledContent += "// attribute " + type + " " + name + array; this->m_compiledContent += "attribute " + type + " " + name + array + ";";
// this->m_compiledContent += "; /* replaced by " + this->lookupReplaceSymbol (name) + " */"; }
// } else
// else {
// { // check for types first
// // check for types first std::string type = this->extractType (it);
// std::string type = this->extractType (it);
// // types not found, try names
// // types not found, try names if (this->m_error == false)
// if (this->m_error == false) {
// { this->m_compiledContent += type;
// this->m_compiledContent += type; }
// } else
// else {
// { this->m_error = false;
// this->m_error = false; std::string name = this->extractName (it);
// std::string name = this->extractName (it);
// if (this->m_error == false)
// if (this->m_error == false) {
// { // check if the name is a translated one or not
// // check if the name is a translated one or not this->m_compiledContent += name;
// this->m_compiledContent += this->lookupReplaceSymbol (name); }
// } else
// else {
// { this->m_error = false;
// this->m_error = false; this->m_compiledContent += *it;
// this->m_compiledContent += *it; it ++;
// it ++; }
// } }
// } }
// } }
// }
else if (*it == '/') else if (*it == '/')
{ {
if (this->peekString ("//", it) == true) if (this->peekString ("//", it) == true)
@ -414,7 +413,7 @@ namespace WallpaperEngine::Render::Shaders
// types not found, try names // types not found, try names
if (this->m_error == false) if (this->m_error == false)
{ {
this->m_compiledContent += type; this->m_compiledContent += type + " ";
} }
else else
{ {
@ -665,6 +664,6 @@ namespace WallpaperEngine::Render::Shaders
std::vector<std::string> Compiler::sTypes = std::vector<std::string> Compiler::sTypes =
{ {
"vec4", "vec3", "vec2", "float", "sampler2D", "mat4" "vec4", "vec3", "vec2", "float", "sampler2D", "mat4x3", "mat4", "uint4"
}; };
} }