opensurgsim
OsgUniformGlslTypes.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2015, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
18 
19 #ifndef SURGSIM_GRAPHICS_OSGUNIFORMGLSLTYPES_H
20 #define SURGSIM_GRAPHICS_OSGUNIFORMGLSLTYPES_H
21 
22 #include<memory>
23 
24 #include "SurgSim/Math/Matrix.h"
25 #include "SurgSim/Math/Vector.h"
26 
27 namespace SurgSim
28 {
29 
30 namespace Graphics
31 {
32 
33 class OsgTexture1d;
34 class OsgTexture2d;
35 class OsgTexture3d;
36 class OsgTextureCubeMap;
37 class OsgTextureRectangle;
38 
44 template <class T>
45 inline const std::string getGlslType()
46 {
47  return "__undefined__";
48 }
49 
50 template <>
51 inline const std::string getGlslType<float>()
52 {
53  return "float";
54 }
55 
56 template <>
57 inline const std::string getGlslType<double>()
58 {
59  return "double";
60 }
61 template <>
62 inline const std::string getGlslType<int>()
63 {
64  return "int";
65 }
66 template <>
67 inline const std::string getGlslType<unsigned int>()
68 {
69  return "uint";
70 }
71 template <>
72 inline const std::string getGlslType<bool>()
73 {
74  return "bool";
75 }
76 
77 template <>
78 inline const std::string getGlslType<SurgSim::Math::Vector2f>()
79 {
80  return "vec2";
81 }
82 template <>
83 inline const std::string getGlslType<SurgSim::Math::Vector3f>()
84 {
85  return "vec3";
86 }
87 template <>
88 inline const std::string getGlslType<SurgSim::Math::Vector4f>()
89 {
90  return "vec4";
91 }
92 
93 template <>
94 inline const std::string getGlslType<SurgSim::Math::Vector2d>()
95 {
96  return "dvec2";
97 }
98 template <>
99 inline const std::string getGlslType<SurgSim::Math::Vector3d>()
100 {
101  return "dvec3";
102 }
103 template <>
104 inline const std::string getGlslType<SurgSim::Math::Vector4d>()
105 {
106  return "dvec4";
107 }
108 
109 template <>
110 inline const std::string getGlslType<SurgSim::Math::Matrix22f>()
111 {
112  return "mat2";
113 }
114 template <>
115 inline const std::string getGlslType<SurgSim::Math::Matrix33f>()
116 {
117  return "mat3";
118 }
119 template <>
120 inline const std::string getGlslType<SurgSim::Math::Matrix44f>()
121 {
122  return "mat4";
123 }
124 
125 template <>
126 inline const std::string getGlslType<SurgSim::Math::Matrix22d>()
127 {
128  return "dmat2";
129 }
130 template <>
131 inline const std::string getGlslType<SurgSim::Math::Matrix33d>()
132 {
133  return "dmat3";
134 }
135 template <>
136 inline const std::string getGlslType<SurgSim::Math::Matrix44d>()
137 {
138  return "dmat4";
139 }
140 
143 template <>
144 inline const std::string getGlslType<std::shared_ptr<OsgTexture1d>>()
145 {
146  return "sampler1D";
147 }
148 
151 template <>
152 inline const std::string getGlslType<std::shared_ptr<OsgTexture2d>>()
153 {
154  return "sampler2D";
155 }
156 
159 template <>
160 inline const std::string getGlslType<std::shared_ptr<OsgTexture3d>>()
161 {
162  return "sampler3D";
163 }
164 
167 template <>
168 inline const std::string getGlslType<std::shared_ptr<OsgTextureCubeMap>>()
169 {
170  return "samplerCube";
171 }
172 
173 template <>
174 inline const std::string getGlslType<std::shared_ptr<OsgTextureRectangle>>()
175 {
176  return "sampler2DRect";
177 }
178 
179 }; // namespace Graphics
180 
181 }; // namespace SurgSim
182 
183 #endif // SURGSIM_GRAPHICS_OSGUNIFORMGLSLTYPES_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Definitions of small fixed-size square matrix types.
Definitions of small fixed-size vector types.
const std::string getGlslType()
Returns the OSG uniform type enum value for the template parameter type.
Definition: OsgUniformGlslTypes.h:45