opensurgsim
Uniform.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_UNIFORM_H
17 #define SURGSIM_GRAPHICS_UNIFORM_H
18 
19 #include "SurgSim/Graphics/UniformBase.h"
20 
21 #include <vector>
22 
23 namespace SurgSim
24 {
25 
26 namespace Graphics
27 {
28 
31 template <class T>
32 class Uniform : public virtual UniformBase
33 {
34 public:
35 
36  Uniform() {
37  SURGSIM_ADD_RW_PROPERTY(Uniform, T, Value, get, set);
38  }
39 
41  virtual void set(const T& value) = 0;
42 
44  virtual const T& get() const = 0;
45 };
46 
49 template <class T>
50 class Uniform<std::vector<T>> : public virtual UniformBase
51 {
52 public:
54  virtual size_t getNumElements() const = 0;
55 
59  virtual void setElement(size_t index, const T& value) = 0;
60 
63  virtual void set(const std::vector<T>& value) = 0;
64 
68  virtual typename std::vector<T>::const_reference getElement(size_t index) const = 0;
69 
72  virtual const std::vector<T>& get() const = 0;
73 };
74 
75 }; // namespace Graphics
76 
77 }; // namespace SurgSim
78 
79 #endif // SURGSIM_GRAPHICS_UNIFORM_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
Base class for a graphics uniform with a value of type T.
Definition: Uniform.h:32
Common base class for all graphics uniforms.
Definition: UniformBase.h:33