Material.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_MATERIAL_H
17 #define SURGSIM_GRAPHICS_MATERIAL_H
18 
19 #include <memory>
20 #include <set>
21 
23 
24 namespace SurgSim
25 {
26 
27 namespace Graphics
28 {
29 
30 class UniformBase;
31 class Shader;
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 
55  virtual bool addUniform(std::shared_ptr<UniformBase> uniform) = 0;
56 
60  virtual bool addUniform(const std::string& type, const std::string& name) = 0;
61 
65  virtual bool removeUniform(std::shared_ptr<UniformBase> uniform) = 0;
66 
70  virtual bool removeUniform(const std::string& name) = 0;
71 
75  virtual std::shared_ptr<UniformBase> getUniform(const std::string& name) const = 0;
76 
80  virtual std::shared_ptr<UniformBase> getUniform(size_t index) const = 0;
81 
85  virtual bool hasUniform(const std::string& name) const = 0;
86 
88  virtual size_t getNumUniforms() const = 0;
89 
90 
94  virtual bool setShader(std::shared_ptr<Shader> shader) = 0;
95 
98  virtual std::shared_ptr<Shader> getShader() const = 0;
99 
101  virtual void clearShader() = 0;
102 };
103 
104 }; // namespace Graphics
105 
106 }; // namespace SurgSim
107 
108 #endif // SURGSIM_GRAPHICS_MATERIAL_H
Definition: DriveElementFromInputBehavior.cpp:27
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.
virtual std::shared_ptr< Shader > getShader() const =0
Gets the shader used by this material.
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:43
Base class that defines the interface for graphics materials.
Definition: Material.h:39
virtual void clearShader()=0
Removes the shader from the material, falling back to fixed-function pipeline.
virtual bool addUniform(std::shared_ptr< UniformBase > uniform)=0
Adds a uniform to this material.
virtual bool setShader(std::shared_ptr< Shader > shader)=0
Sets the shader used by 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 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.