opensurgsim
OsgUniform.h
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 
16 #ifndef SURGSIM_GRAPHICS_OSGUNIFORM_H
17 #define SURGSIM_GRAPHICS_OSGUNIFORM_H
18 
19 #include "SurgSim/Graphics/OsgUniformBase.h"
20 #include "SurgSim/Graphics/Uniform.h"
21 
22 namespace YAML
23 {
24 class Node;
25 }
26 
27 namespace SurgSim
28 {
29 
30 namespace Graphics
31 {
32 
35 template <class T>
36 class OsgUniform : public Uniform<T>, public OsgUniformBase
37 {
38 public:
41  explicit OsgUniform(const std::string& name);
42 
45  virtual void set(const T& value);
46 
49  virtual void set(const YAML::Node& node);
50 
52  virtual const T& get() const;
53 
54  const std::string getGlslType() const override;
55 
56 private:
58  T m_value;
59 };
60 
63 template <class T>
64 class OsgUniform<std::vector<T>> : public Uniform<std::vector<T>>, public OsgUniformBase
65 {
66 public:
70  OsgUniform(const std::string& name, size_t numElements);
71 
73  virtual size_t getNumElements() const;
74 
78  virtual void setElement(size_t index, const T& value);
79 
82  virtual void set(const std::vector<T>& value);
83 
87  virtual void set(const YAML::Node& node);
88 
92  virtual typename std::vector<T>::const_reference getElement(size_t index) const;
93 
96  virtual const std::vector<T>& get() const;
97 
98  const std::string getGlslType() const override;
99 
100 private:
102  std::vector<T> m_value;
103 };
104 
105 }; // namespace Graphics
106 
107 }; // namespace SurgSim
108 
109 #include "SurgSim/Graphics/OsgUniform-inl.h"
110 
115 #include "SurgSim/Graphics/OsgTextureUniform.h"
116 #include "SurgSim/Graphics/OsgTextureUniform-inl.h"
117 
118 #endif // SURGSIM_GRAPHICS_OSGUNIFORM_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Definition: MockObjects.h:47
OSG implementation of graphics uniform with a value of type T.
Definition: OsgCamera.h:46
Base OSG implementation of graphics uniforms.
Definition: OsgUniformBase.h:41
Base class for a graphics uniform with a value of type T.
Definition: Uniform.h:32
Definition: DataStructuresConvert.h:28
const std::string getGlslType()
Returns the OSG uniform type enum value for the template parameter type.
Definition: OsgUniformGlslTypes.h:45