Shader.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_SHADER_H
17 #define SURGSIM_GRAPHICS_SHADER_H
18 
19 #include <string>
20 
21 namespace SurgSim
22 {
23 
24 namespace Graphics
25 {
26 
30 class Shader
31 {
32 public:
34  virtual ~Shader() = 0;
35 
37  virtual bool hasVertexShader() const = 0;
38 
40  virtual void clearVertexShader() = 0;
41 
45  virtual bool loadVertexShaderSource(const std::string& filePath) = 0;
46 
49  virtual void setVertexShaderSource(const std::string& source) = 0;
50 
53  virtual bool getVertexShaderSource(std::string* source) const = 0;
54 
56  virtual bool hasGeometryShader() const = 0;
57 
59  virtual void clearGeometryShader() = 0;
60 
64  virtual bool loadGeometryShaderSource(const std::string& filePath) = 0;
65 
68  virtual void setGeometryShaderSource(const std::string& source) = 0;
69 
72  virtual bool getGeometryShaderSource(std::string* source) const = 0;
73 
74 
76  virtual bool hasFragmentShader() const = 0;
77 
79  virtual void clearFragmentShader() = 0;
80 
84  virtual bool loadFragmentShaderSource(const std::string& filePath) = 0;
85 
88  virtual void setFragmentShaderSource(const std::string& source) = 0;
89 
92  virtual bool getFragmentShaderSource(std::string* source) const = 0;
93 
95  virtual void clear()
96  {
100  }
101 
107  virtual void setGlobalScope(bool val) = 0;
108 
111  virtual bool isGlobalScope() const = 0;
112 
113 };
114 
116 {
117 }
118 
119 }; // namespace Graphics
120 
121 }; // namespace SurgSim
122 
123 #endif // SURGSIM_GRAPHICS_SHADER_H
virtual bool loadVertexShaderSource(const std::string &filePath)=0
Loads the vertex shader source code from a file.
Definition: DriveElementFromInputBehavior.cpp:27
virtual bool loadFragmentShaderSource(const std::string &filePath)=0
Loads the fragment shader source code from a file.
virtual void setVertexShaderSource(const std::string &source)=0
Set the vertex shader source code.
virtual bool getGeometryShaderSource(std::string *source) const =0
Gets the geometry shader source code.
virtual bool getVertexShaderSource(std::string *source) const =0
Gets the vertex shader source code.
virtual bool getFragmentShaderSource(std::string *source) const =0
Gets the fragment shader source code.
virtual bool loadGeometryShaderSource(const std::string &filePath)=0
Loads the geometry shader source code from a file.
Base class that defines the interface for graphics shaders.
Definition: Shader.h:30
virtual bool hasGeometryShader() const =0
Returns true if the geometry shader has been set, otherwise false.
virtual bool hasVertexShader() const =0
Returns true if the vertex shader has been set, otherwise false.
virtual ~Shader()=0
Destructor.
Definition: Shader.h:115
virtual bool isGlobalScope() const =0
Query if this shader is of global scope.
virtual void clearFragmentShader()=0
Removes the fragment shader, returning that portion of the shader program to fixed-function.
virtual void setGlobalScope(bool val)=0
When this is set to true, this shader should be used instead of other shaders that might apply...
virtual bool hasFragmentShader() const =0
Returns true if the fragment shader has been set, otherwise false.
virtual void clear()
Clears the entire shader, returning to fixed-function pipeline.
Definition: Shader.h:95
virtual void setFragmentShaderSource(const std::string &source)=0
Set the fragment shader source code.
virtual void clearVertexShader()=0
Removes the vertex shader, returning that portion of the shader program to fixed-function.
virtual void setGeometryShaderSource(const std::string &source)=0
Set the geometry shader source code.
virtual void clearGeometryShader()=0
Removes the geometry shader, returning that portion of the shader program to fixed-function.