opensurgsim
OsgUniformTypes.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, 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_OSGUNIFORMTYPES_H
20 #define SURGSIM_GRAPHICS_OSGUNIFORMTYPES_H
21 
22 #include<memory>
23 
24 #include "SurgSim/Math/Matrix.h"
25 #include "SurgSim/Math/Vector.h"
26 
27 #include <osg/Uniform>
28 
29 namespace SurgSim
30 {
31 
32 namespace Graphics
33 {
34 
35 class OsgTexture1d;
36 class OsgTexture2d;
37 class OsgTexture3d;
38 class OsgTextureCubeMap;
39 class OsgTextureRectangle;
40 
46 template <class T>
47 inline osg::Uniform::Type getOsgUniformType()
48 {
49  return osg::Uniform::UNDEFINED;
50 }
51 
52 template <>
53 inline osg::Uniform::Type getOsgUniformType<float>()
54 {
55  return osg::Uniform::FLOAT;
56 }
57 template <>
58 inline osg::Uniform::Type getOsgUniformType<double>()
59 {
60  return osg::Uniform::DOUBLE;
61 }
62 template <>
63 inline osg::Uniform::Type getOsgUniformType<int>()
64 {
65  return osg::Uniform::INT;
66 }
67 template <>
68 inline osg::Uniform::Type getOsgUniformType<unsigned int>()
69 {
70  return osg::Uniform::UNSIGNED_INT;
71 }
72 template <>
73 inline osg::Uniform::Type getOsgUniformType<bool>()
74 {
75  return osg::Uniform::BOOL;
76 }
77 
78 template <>
79 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Vector2f>()
80 {
81  return osg::Uniform::FLOAT_VEC2;
82 }
83 template <>
84 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Vector3f>()
85 {
86  return osg::Uniform::FLOAT_VEC3;
87 }
88 template <>
89 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Vector4f>()
90 {
91  return osg::Uniform::FLOAT_VEC4;
92 }
93 
94 template <>
95 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Vector2d>()
96 {
97  return osg::Uniform::DOUBLE_VEC2;
98 }
99 template <>
100 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Vector3d>()
101 {
102  return osg::Uniform::DOUBLE_VEC3;
103 }
104 template <>
105 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Vector4d>()
106 {
107  return osg::Uniform::DOUBLE_VEC4;
108 }
109 
110 template <>
111 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Matrix22f>()
112 {
113  return osg::Uniform::FLOAT_MAT2;
114 }
115 template <>
116 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Matrix33f>()
117 {
118  return osg::Uniform::FLOAT_MAT3;
119 }
120 template <>
121 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Matrix44f>()
122 {
123  return osg::Uniform::FLOAT_MAT4;
124 }
125 
126 template <>
127 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Matrix22d>()
128 {
129  return osg::Uniform::DOUBLE_MAT2;
130 }
131 template <>
132 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Matrix33d>()
133 {
134  return osg::Uniform::DOUBLE_MAT3;
135 }
136 template <>
137 inline osg::Uniform::Type getOsgUniformType<SurgSim::Math::Matrix44d>()
138 {
139  return osg::Uniform::DOUBLE_MAT4;
140 }
141 
142 template <>
143 inline osg::Uniform::Type getOsgUniformType<std::shared_ptr<OsgTexture1d>>()
144 {
145  return osg::Uniform::SAMPLER_1D;
146 }
147 
148 template <>
149 inline osg::Uniform::Type getOsgUniformType<std::shared_ptr<OsgTexture2d>>()
150 {
151  return osg::Uniform::SAMPLER_2D;
152 }
153 
154 template <>
155 inline osg::Uniform::Type getOsgUniformType<std::shared_ptr<OsgTexture3d>>()
156 {
157  return osg::Uniform::SAMPLER_3D;
158 }
159 
160 template <>
161 inline osg::Uniform::Type getOsgUniformType<std::shared_ptr<OsgTextureCubeMap>>()
162 {
163  return osg::Uniform::SAMPLER_CUBE;
164 }
165 
166 template <>
167 inline osg::Uniform::Type getOsgUniformType<std::shared_ptr<OsgTextureRectangle>>()
168 {
169  return osg::Uniform::SAMPLER_2D_RECT;
170 }
171 
172 }; // namespace Graphics
173 
174 }; // namespace SurgSim
175 
176 #endif // SURGSIM_GRAPHICS_OSGUNIFORMTYPES_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
osg::Uniform::Type getOsgUniformType()
Returns the OSG uniform type enum value for the template parameter type.
Definition: OsgUniformTypes.h:47
Definitions of small fixed-size square matrix types.
Definitions of small fixed-size vector types.