opensurgsim
Material.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, 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_MATERIAL_H
17 #define SURGSIM_GRAPHICS_MATERIAL_H
18 
19 #include <memory>
20 #include <set>
21 
22 #include "SurgSim/Framework/Component.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace Graphics
28 {
29 
30 class UniformBase;
31 class Program;
32 
40 {
41 public:
42 
44  explicit Material(const std::string& name) : Component(name) {}
45 
47  // (Note that Visual Studio does not support "= default" yet.)
48  virtual ~Material()
49  {
50  }
51 
54  virtual void addUniform(std::shared_ptr<UniformBase> uniform) = 0;
55 
59  virtual void addUniform(const std::string& type, const std::string& name) = 0;
60 
64  virtual bool removeUniform(std::shared_ptr<UniformBase> uniform) = 0;
65 
69  virtual bool removeUniform(const std::string& name) = 0;
70 
74  virtual std::shared_ptr<UniformBase> getUniform(const std::string& name) const = 0;
75 
79  virtual std::shared_ptr<UniformBase> getUniform(size_t index) const = 0;
80 
84  virtual bool hasUniform(const std::string& name) const = 0;
85 
87  virtual size_t getNumUniforms() const = 0;
88 
89  virtual void loadProgram(const std::string& nameTuple) = 0;
90 
91 
95  virtual bool setProgram(std::shared_ptr<Program> program) = 0;
96 
99  virtual std::shared_ptr<Program> getProgram() const = 0;
100 
102  virtual void clearProgram() = 0;
103 };
104 
105 }; // namespace Graphics
106 
107 }; // namespace SurgSim
108 
109 #endif // SURGSIM_GRAPHICS_MATERIAL_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
virtual ~Material()
Destructor.
Definition: Material.h:48
Component(const std::string &name)
Constructor.
Definition: Component.cpp:34
virtual size_t getNumUniforms() const =0
Returns the number of uniforms in this material.
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:42
Base class that defines the interface for graphics materials.
Definition: Material.h:39
virtual std::shared_ptr< Program > getProgram() const =0
Gets the program used by this material.
virtual bool setProgram(std::shared_ptr< Program > program)=0
Sets the program used by this material.
virtual void addUniform(std::shared_ptr< UniformBase > uniform)=0
Adds a uniform to this material.
Material(const std::string &name)
Constructor.
Definition: Material.h:44
virtual bool removeUniform(std::shared_ptr< UniformBase > uniform)=0
Removes a uniform from this material.
virtual void clearProgram()=0
Removes the shader from the material, falling back to fixed-function pipeline.
virtual std::shared_ptr< UniformBase > getUniform(const std::string &name) const =0
Gets a uniform in this material.
virtual bool hasUniform(const std::string &name) const =0
Checks if this material has a uniform with the given name.