Privacy
An open-source, flexible 3D physical simulation framework
shader-types.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016, DFKI GmbH Robotics Innovation Center
3  *
4  * This file is part of the MARS simulation framework.
5  *
6  * MARS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3
9  * of the License, or (at your option) any later version.
10  *
11  * MARS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with MARS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 #ifndef OSG_MATERIAL_MANAGER_SHADER_TYPES_H
23 #define OSG_MATERIAL_MANAGER_SHADER_TYPES_H
24 
25 #include <string>
26 #include <ostream>
27 #include <vector>
28 
29 namespace osg_material_manager {
30 
31  typedef struct {
32  std::string type;
33  std::string name;
34  } GLSLAttribute;
35 
39 
40  typedef struct {
41  std::string name;
42  std::string value;
43  } GLSLExport;
44 
45  typedef struct {
46  std::string type;
47  std::string name;
48  std::string value;
49  } GLSLVariable;
50 
52 
53 
54  typedef struct PrioritizedValue {
55  int priority;
56  int s_priority; // used to preserve order in case of same priority
57  bool operator<(const PrioritizedValue& other) const {
58  if (priority == other.priority) {
59  return s_priority > other.s_priority;
60  }
61  return priority > other.priority;
62  };
64 
65  typedef struct FunctionCall : PrioritizedValue {
66  std::string name;
67  std::vector<std::string> arguments;
68  FunctionCall(std::string name, std::vector<std::string> args, int prio, int s_prio) : name(name), arguments(args) {
69  priority = prio;
70  }
71  std::string toString() const {
72  std::string call = name + "( ";
73  unsigned long numArgs = arguments.size();
74 
75  if(numArgs > 0) {
76  call += arguments[0];
77  for(int i=1; i<numArgs; ++i) {
78  call += ", " + arguments[i];
79  }
80  }
81  call += " )";
82  return call;
83  }
84  } FunctionCall;
85 
87  MainVar(std::string p_name, std::string p_type, std::string p_value, int p_priority, int p_s_priority) {
88  priority = p_priority;
89  s_priority = p_s_priority;
90  name = p_name;
91  value = p_value;
92  type = p_type;
93  }
94  std::string toString() const {
95  return name + " = " + value;
96  }
97  } MainVar;
98 
99  typedef struct PrioritizedLine : PrioritizedValue {
100  std::string line;
101  PrioritizedLine(std::string p_line, int p_priority, int p_s_priority) : line(p_line) {
102  priority = p_priority;
103  s_priority = p_s_priority;
104  }
105  };
106 
107  std::ostream& operator<<(std::ostream& os, const GLSLAttribute& a);
108  std::ostream& operator<<(std::ostream& os, const GLSLExport& a);
109  std::ostream& operator<<(std::ostream& os, const GLSLVariable& a);
110  bool operator<(const GLSLAttribute& a, const GLSLAttribute& b);
111  bool operator<(const GLSLExport& a, const GLSLExport& b);
112  bool operator<(const GLSLVariable& a, const GLSLVariable& b);
113 
114 } // end of namespace osg_material_manager
115 
116 #endif /* OSG_MATERIAL_MANAGER_SHADER_TYPES_H */
117 
u_int8_t b
Definition: CameraSensor.h:43
ostream & operator<<(ostream &os, const GLSLExport &a)
GLSLAttribute GLSLUniform
Definition: shader-types.h:37
u_int8_t a
Definition: CameraSensor.h:44
struct osg_material_manager::PrioritizedValue PrioritizedValue
MainVar(std::string p_name, std::string p_type, std::string p_value, int p_priority, int p_s_priority)
Definition: shader-types.h:87
GLSLVariable GLSLConstant
Definition: shader-types.h:51
std::string toString() const
Definition: shader-types.h:94
bool operator<(const PrioritizedValue &other) const
Definition: shader-types.h:57
FunctionCall(std::string name, std::vector< std::string > args, int prio, int s_prio)
Definition: shader-types.h:68
osg_material_manager::FunctionCall FunctionCall
PrioritizedLine(std::string p_line, int p_priority, int p_s_priority)
Definition: shader-types.h:101
osg_material_manager::MainVar MainVar
GLSLAttribute GLSLVarying
Definition: shader-types.h:36
std::vector< std::string > arguments
Definition: shader-types.h:67
GLSLAttribute GLSLSuffix
Definition: shader-types.h:38