OsgUniformBase.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 
16 #ifndef SURGSIM_GRAPHICS_OSGUNIFORMBASE_H
17 #define SURGSIM_GRAPHICS_OSGUNIFORMBASE_H
18 
20 
21 #include <osg/StateSet>
22 #include <osg/Uniform>
23 
24 namespace SurgSim
25 {
26 
27 namespace Graphics
28 {
29 
36 class OsgUniformBase : public virtual UniformBase
37 {
38 public:
40  const std::string& getName() const
41  {
42  return m_uniform->getName();
43  }
44 
47  virtual void addToStateSet(osg::StateSet* stateSet);
48 
51  virtual void removeFromStateSet(osg::StateSet* stateSet);
52 
54  osg::ref_ptr<osg::Uniform> getOsgUniform() const
55  {
56  return m_uniform;
57  }
58 
59 protected:
62  explicit OsgUniformBase(const std::string& name);
63 
65  osg::ref_ptr<osg::Uniform> m_uniform;
66 };
67 
68 }; // namespace Graphics
69 
70 }; // namespace SurgSim
71 
72 #endif // SURGSIM_GRAPHICS_OSGUNIFORMBASE_H
Definition: DriveElementFromInputBehavior.cpp:27
const std::string & getName() const
Returns the name used in shader code to access this uniform.
Definition: OsgUniformBase.h:40
virtual void addToStateSet(osg::StateSet *stateSet)
Adds this uniform to the OSG state set.
Definition: OsgUniformBase.cpp:27
osg::ref_ptr< osg::Uniform > m_uniform
OSG uniform node.
Definition: OsgUniformBase.h:65
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
virtual void removeFromStateSet(osg::StateSet *stateSet)
Removes this uniform from the OSG state set.
Definition: OsgUniformBase.cpp:33
Base OSG implementation of graphics uniforms.
Definition: OsgUniformBase.h:36
osg::ref_ptr< osg::Uniform > getOsgUniform() const
Returns the OSG uniform node.
Definition: OsgUniformBase.h:54
OsgUniformBase(const std::string &name)
Constructor.
Definition: OsgUniformBase.cpp:21
Common base class for all graphics uniforms.
Definition: UniformBase.h:33