Skip to content

Commit c572928

Browse files
author
Vallyah
committed
Fix : Shader now able to compile when using ColorNode on french OS
1 parent 03d107d commit c572928

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

source/model/Node.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <list>
55
#include <vector>
66
#include <string>
7+
#include <sstream>
78

89
#include <QVBoxLayout>
910
#include <QLayoutItem>
@@ -26,6 +27,15 @@ namespace QtNodes { class Connection; }
2627

2728
namespace ShaderGraph
2829
{
30+
// function used to avoid float to string conversion with comas from french OS
31+
template<typename T> std::string to_str(const T a_value, const int precision = 6)
32+
{
33+
std::ostringstream out;
34+
out.precision(precision);
35+
out << std::fixed << a_value;
36+
return out.str();
37+
}
38+
2939
/// The node ID factory.
3040
static unsigned int g_nodeId = 0;
3141
#define GET_NEW_NODE_ID g_nodeId++

source/model/input/ColorNode.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ namespace ShaderGraph
5757
/// @warning : Only valid if @isUniform equals true.
5858
inline std::string getUniformDefaultValue() override
5959
{
60+
// function to_str defined in model/Node.h and used to avoid
61+
// float to string conversion with comas from french OS
6062
return "vec4(" +
61-
std::to_string(m_rSpinBox->value()) + ", " +
62-
std::to_string(m_gSpinBox->value()) + ", " +
63-
std::to_string(m_bSpinBox->value()) + ", " +
64-
std::to_string(m_aSpinBox->value()) + ") " ;
63+
to_str(m_rSpinBox->value()) + ", " +
64+
to_str(m_gSpinBox->value()) + ", " +
65+
to_str(m_bSpinBox->value()) + ", " +
66+
to_str(m_aSpinBox->value()) + ") " ;
6567
};
6668

6769
GLSLData nodeToGLSL() override;

source/model/input/VectorNode.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@
1919

2020
namespace ShaderGraph
2121
{
22-
template<typename T> std::string to_str(const T a_value, const int precision = 6)
23-
{
24-
std::ostringstream out;
25-
out.precision(precision);
26-
out << std::fixed << a_value;
27-
return out.str();
28-
}
29-
3022
class ScalarNode : public Node
3123
{
3224
Q_OBJECT
@@ -59,6 +51,8 @@ namespace ShaderGraph
5951
GLSLData nodeToGLSL() override
6052
{
6153
GLSLData buffer;
54+
// function to_str defined in model/Node.h and used to avoid
55+
// float to string conversion with comas from french OS
6256
GLSL_CODE(buffer.generatedCode,
6357
"// Input : Scalar \n"
6458
"{0} = {1};"
@@ -128,6 +122,8 @@ namespace ShaderGraph
128122
GLSLData nodeToGLSL() override
129123
{
130124
GLSLData buffer;
125+
// function to_str defined in model/Node.h and used to avoid
126+
// float to string conversion with comas from french OS
131127
GLSL_CODE(buffer.generatedCode,
132128
"// Input : Vec2 \n"
133129
"{0} = vec2({1}, {2});"
@@ -207,6 +203,8 @@ namespace ShaderGraph
207203
GLSLData nodeToGLSL() override
208204
{
209205
GLSLData buffer;
206+
// function to_str defined in model/Node.h and used to avoid
207+
// float to string conversion with comas from french OS
210208
GLSL_CODE(buffer.generatedCode,
211209
"// Input : Vec3 \n"
212210
"{0} = vec3({1}, {2}, {3});"
@@ -297,6 +295,8 @@ namespace ShaderGraph
297295
GLSLData nodeToGLSL() override
298296
{
299297
GLSLData buffer;
298+
// function to_str defined in model/Node.h and used to avoid
299+
// float to string conversion with comas from french OS
300300
GLSL_CODE(buffer.generatedCode,
301301
"// Input : Vec4 \n"
302302
"{0} = vec4({1}, {2}, {3}, {4});"

0 commit comments

Comments
 (0)