Skip to content

Commit 219b4bf

Browse files
committed
Better fix for repetitive spire messages
1 parent 3ba8d71 commit 219b4bf

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

src/Externals/spire/es-cereal/ComponentSerialize.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ class ComponentSerializeInterface
185185
virtual const char* getComponentName() const = 0;
186186
};
187187

188+
class RepetitiveMessageTracker
189+
{
190+
public:
191+
static bool hasPostedFor(const std::string& className, int glIdNumber, const std::string& objectName);
192+
private:
193+
static std::map<std::string, std::map<int, std::map<std::string, bool>>> tracking_;
194+
};
195+
188196
} // namespace spire
189197

190198
#endif

src/Externals/spire/es-render/comp/MatUniform.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ void MatUniform::checkUniform(GLuint shaderID)
7070
}
7171
}
7272

73-
if (boundUniform == false)
73+
if (!boundUniform)
7474
{
75-
std::cerr << "Unable to find uniform with name: " << uniformName <<
76-
" in shader with ID: " << shaderID << std::endl;
75+
if (!spire::RepetitiveMessageTracker::hasPostedFor("MatUniform", shaderID, uniformName))
76+
{
77+
std::cerr << "Unable to find uniform with name: " << uniformName <<
78+
" in shader with ID: " << shaderID << std::endl;
79+
}
7780
}
7881
}
7982

src/Externals/spire/es-render/comp/Texture.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,24 @@
3535

3636
namespace shaders = spire;
3737

38-
namespace ren {
38+
bool spire::RepetitiveMessageTracker::hasPostedFor(const std::string& className, int glIdNumber, const std::string& objectName)
39+
{
40+
bool trackedBefore = tracking_[className][glIdNumber][objectName];
41+
if (trackedBefore)
42+
{
43+
return true;
44+
}
45+
else
46+
{
47+
tracking_[className][glIdNumber][objectName] = true;
48+
std::cerr << "[RENDERER LOG] ";
49+
return false;
50+
}
51+
}
52+
53+
std::map<std::string, std::map<int, std::map<std::string, bool>>> spire::RepetitiveMessageTracker::tracking_;
3954

40-
static std::map<int, std::map<std::string, bool>> textureUniformLogged;
55+
namespace ren {
4156

4257
void Texture::checkUniform(GLuint shaderID)
4358
{
@@ -57,11 +72,13 @@ void Texture::checkUniform(GLuint shaderID)
5772
}
5873
}
5974

60-
if (!boundUniform && textureUniformLogged[shaderID].find(uniformName) == textureUniformLogged[shaderID].end())
75+
if (!boundUniform)
6176
{
62-
std::cerr << "Unable to find uniform with name: " << uniformName <<
77+
if (!spire::RepetitiveMessageTracker::hasPostedFor("Texture", shaderID, uniformName))
78+
{
79+
std::cerr << "Unable to find uniform with name: " << uniformName <<
6380
" in shader with ID: " << shaderID << std::endl;
64-
textureUniformLogged[shaderID][uniformName] = true;
81+
}
6582
}
6683
}
6784
}

src/Externals/spire/es-render/comp/VecUniform.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ void VecUniform::checkUniform(GLuint shaderID)
8181
}
8282
}
8383

84-
if (boundUniform == false)
84+
if (!boundUniform)
8585
{
86-
std::cerr << "Unable to find uniform with name: " << uniformName <<
87-
" in shader with ID: " << shaderID << std::endl;
86+
if (!spire::RepetitiveMessageTracker::hasPostedFor("VecUniform", shaderID, uniformName))
87+
{
88+
std::cerr << "Unable to find uniform with name: " << uniformName << " in shader with ID: "
89+
<< shaderID << std::endl;
90+
}
8891
}
8992
}
9093

src/Externals/spire/es-render/util/TexQuad.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ glm::mat4 getTexQuadTransform(const glm::vec3& center, float width, float height
144144

145145
glm::mat4 getTexQuadTransform(const glm::vec2& topLeft, const glm::vec2& bottomRight, float z)
146146
{
147-
glm::mat4 trafo;
148147
float width = bottomRight.x - topLeft.x;
149148
float height = topLeft.y - bottomRight.y;
150149
glm::vec3 center = glm::vec3(width / 2.0f, height / 2.0f, z);

0 commit comments

Comments
 (0)