Vuo  2.3.2
VuoShaderIssues.cc
Go to the documentation of this file.
1 
10 #include "VuoShaderIssues.hh"
11 
12 #include "VuoStringUtilities.hh"
13 
14 const int VuoShaderIssues::NoLine = INT_MAX;
15 const int VuoShaderIssues::PreambleLine = 1000000000;
16 
17 #include <sstream>
18 
22 void VuoShaderIssues::addIssue(VuoShaderFile::Stage stage, int lineNumber, std::string message)
23 {
24  // Ignore innocuous warning.
25  if (stage == VuoShaderFile::Program && message == "Output of vertex shader 'isf_FragNormCoord' not read by fragment shader")
26  return;
27 
28  ostringstream oss;
29 
30  oss << message;
31 
32  if (!VuoStringUtilities::endsWith(message, ")"))
33  {
34  if (stage != VuoShaderFile::Program)
35  oss << " (" << VuoShaderFile::stageName(stage);
36 
37  if (isUserEnteredLine(lineNumber))
38  oss << " line " << lineNumber << ")";
39  else if (stage != VuoShaderFile::Program)
40  oss << ")";
41  }
42 
43  _issues.push_back((Issue){stage, lineNumber, oss.str()});
44 }
45 
49 vector<VuoShaderIssues::Issue> &VuoShaderIssues::issues()
50 {
51  return _issues;
52 }
53 
57 vector<VuoShaderIssues::Issue> VuoShaderIssues::issuesForStage(VuoShaderFile::Stage stage)
58 {
59  vector<VuoShaderIssues::Issue> stageIssues;
60  for (vector<Issue>::iterator it = _issues.begin(); it != _issues.end(); ++it)
61  if (it->stage == stage)
62  stageIssues.push_back(*it);
63  return stageIssues;
64 }
65 
71 {
72  return (lineNumber != NoLine
73  && lineNumber < PreambleLine);
74 }
75 
80 {
81  for (vector<Issue>::iterator it = _issues.begin(); it != _issues.end(); ++it)
82  VUserLog("%s", it->message.c_str());
83 }