From 2473265541bb1982dfe4767428e860534c98eaa3 Mon Sep 17 00:00:00 2001 From: Amr Essam Date: Thu, 26 Oct 2023 17:41:54 +0300 Subject: [PATCH] QmlDesigner: Fix issues related to uniforms Some types were parsed wrong for shader values Change-Id: I4301d671dfa7bde1f23feacd64ceb5f0f9d247b9 Reviewed-by: Reviewed-by: Qt CI Patch Build Bot Reviewed-by: Mahmoud Badri --- src/plugins/effectmakernew/effectmakermodel.cpp | 4 ++-- src/plugins/effectmakernew/uniform.cpp | 6 +++--- src/plugins/effectmakernew/uniform.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/effectmakernew/effectmakermodel.cpp b/src/plugins/effectmakernew/effectmakermodel.cpp index 1cdbcf94efb..4e4bcacbdea 100644 --- a/src/plugins/effectmakernew/effectmakermodel.cpp +++ b/src/plugins/effectmakernew/effectmakermodel.cpp @@ -230,7 +230,7 @@ const QString EffectMakerModel::getBufUniform() for (const auto uniform : uniforms) { // TODO: Check if uniform is already added. if (uniform->type() != Uniform::Type::Sampler && uniform->type() != Uniform::Type::Define) { - QString type = Uniform::stringFromType(uniform->type()); + QString type = Uniform::stringFromType(uniform->type(), true); QString props = " " + type + " " + uniform->name() + ";\n"; s += props; } @@ -480,7 +480,7 @@ const QString EffectMakerModel::getConstVariables() for (Uniform *uniform : uniforms) { // TODO: Check if uniform is already added. QString constValue = valueAsVariable(*uniform); - QString type = Uniform::stringFromType(uniform->type()); + QString type = Uniform::stringFromType(uniform->type(), true); s += QString("const %1 %2 = %3;\n").arg(type, uniform->name(), constValue); } if (!s.isEmpty()) diff --git a/src/plugins/effectmakernew/uniform.cpp b/src/plugins/effectmakernew/uniform.cpp index 631421bc53b..370adddc949 100644 --- a/src/plugins/effectmakernew/uniform.cpp +++ b/src/plugins/effectmakernew/uniform.cpp @@ -63,7 +63,7 @@ Uniform::Type Uniform::type() const // String representation of the type for qml QString Uniform::typeName() const { - return Uniform::stringFromType(m_type); + return Uniform::stringFromType(m_type, false); } QVariant Uniform::value() const @@ -258,7 +258,7 @@ QVariant Uniform::valueStringToVariant(const QString &value) return variant; } -QString Uniform::stringFromType(Uniform::Type type) +QString Uniform::stringFromType(Uniform::Type type, bool isShader) { if (type == Type::Bool) return "bool"; @@ -273,7 +273,7 @@ QString Uniform::stringFromType(Uniform::Type type) else if (type == Type::Vec4) return "vec4"; else if (type == Type::Color) - return "color"; + return isShader ? QString("vec4") : QString("color"); else if (type == Type::Sampler) return "sampler2D"; else if (type == Type::Define) diff --git a/src/plugins/effectmakernew/uniform.h b/src/plugins/effectmakernew/uniform.h index 1fe2530cacd..370c720410b 100644 --- a/src/plugins/effectmakernew/uniform.h +++ b/src/plugins/effectmakernew/uniform.h @@ -69,7 +69,7 @@ public: bool enableMipmap() const; - static QString stringFromType(Uniform::Type type); + static QString stringFromType(Uniform::Type type, bool isShader); static Uniform::Type typeFromString(const QString &typeString); static QString typeToProperty(Uniform::Type type);