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 YAML
25 {
26 class Node;
27 }
28 
29 namespace SurgSim
30 {
31 
32 namespace Graphics
33 {
34 
41 class OsgUniformBase : public virtual UniformBase
42 {
43 public:
45  const std::string& getName() const
46  {
47  return m_uniform->getName();
48  }
49 
53  virtual void set(const YAML::Node& node) = 0;
54 
57  virtual void addToStateSet(osg::StateSet* stateSet);
58 
61  virtual void removeFromStateSet(osg::StateSet* stateSet);
62 
64  osg::ref_ptr<osg::Uniform> getOsgUniform() const
65  {
66  return m_uniform;
67  }
68 
69 protected:
72  explicit OsgUniformBase(const std::string& name);
73 
75  osg::ref_ptr<osg::Uniform> m_uniform;
76 };
77 
78 }; // namespace Graphics
79 
80 }; // namespace SurgSim
81 
82 #endif // SURGSIM_GRAPHICS_OSGUNIFORMBASE_H
Definition: CompoundShapeToGraphics.cpp:29
osg::ref_ptr< osg::Uniform > m_uniform
OSG uniform node.
Definition: OsgUniformBase.h:75
Base OSG implementation of graphics uniforms.
Definition: OsgUniformBase.h:41
osg::ref_ptr< osg::Uniform > getOsgUniform() const
Returns the OSG uniform node.
Definition: OsgUniformBase.h:64
Definition: DataStructuresConvert.h:28
const std::string & getName() const
Returns the name used in shader code to access this uniform.
Definition: OsgUniformBase.h:45
Common base class for all graphics uniforms.
Definition: UniformBase.h:33