Go to the documentation of this file.
16 #ifndef SURGSIM_GRAPHICS_OSGPROGRAM_H
17 #define SURGSIM_GRAPHICS_OSGPROGRAM_H
21 #include <osg/Program>
22 #include <osg/StateSet>
32 class ApplicationData;
129 virtual void setShaderSource(
const std::string& source,
int shaderType);
133 virtual bool getShaderSource(
int shaderType, std::string* source)
const;
150 const std::string& name);
158 const std::string& vertexShaderName,
const std::string& fragmentShaderName);
164 #endif // SURGSIM_GRAPHICS_OSGPROGRAM_H
OSG-based implementation of a graphics shader.
Definition: OsgProgram.h:43
bool getGeometryShaderSource(std::string *source) const override
Gets the geometry shader source code.
Definition: OsgProgram.cpp:99
void clearGeometryShader() override
Removes the geometry shader, returning that portion of the shader program to fixed-function.
Definition: OsgProgram.cpp:84
void clearVertexShader() override
Removes the vertex shader, returning that portion of the shader program to fixed-function.
Definition: OsgProgram.cpp:59
void addToStateSet(osg::StateSet *stateSet)
Adds this shader to the OSG state set.
Definition: OsgProgram.cpp:37
Definition: OsgProgram.h:105
bool loadFragmentShader(const std::string &filePath) override
Loads the fragment shader source code from a file.
Definition: OsgProgram.cpp:114
bool hasShader(int shaderType) const
Check whether there is a shader in use for the given type.
Definition: OsgProgram.cpp:149
osg::ref_ptr< osg::Program > m_program
OSG program attribute.
Definition: OsgProgram.h:97
Definition: OsgProgram.h:102
Definition: OsgProgram.h:103
virtual void setShaderSource(const std::string &source, int shaderType)
Set the shader source code.
Definition: OsgProgram.cpp:181
bool loadGeometryShader(const std::string &filePath) override
Loads the geometry shader source code from a file.
Definition: OsgProgram.cpp:89
void clearShader(int shaderType)
Removes the geometry shader, returning that portion of the shader program to fixed-function.
Definition: OsgProgram.cpp:159
bool hasFragmentShader() const override
Definition: OsgProgram.cpp:104
Definition: CompoundShapeToGraphics.cpp:29
void setVertexShaderSource(const std::string &source) override
Set the vertex shader source code.
Definition: OsgProgram.cpp:69
void clearFragmentShader() override
Definition: OsgProgram.cpp:109
Base class that defines the interface for graphics programs.
Definition: Program.h:39
bool m_globalScope
Is the shader supposed to be used globally.
Definition: OsgProgram.h:141
ShaderType
Definition: OsgProgram.h:100
void setFragmentShaderSource(const std::string &source) override
Set the fragment shader source code.
Definition: OsgProgram.cpp:119
OsgProgram()
Constructor.
Definition: OsgProgram.cpp:30
osg::ref_ptr< osg::Shader > getOrCreateOsgShader(int shaderType)
Fetches the appropriate shader if it exists, creates it otherwise.
Definition: OsgProgram.cpp:201
bool loadShaderSource(const std::string &filePath, int shaderType)
Loads the shader source code from a file.
Definition: OsgProgram.cpp:168
bool hasVertexShader() const override
Definition: OsgProgram.cpp:54
bool loadVertexShader(const std::string &filePath) override
Loads the vertex shader source code from a file.
Definition: OsgProgram.cpp:64
std::shared_ptr< OsgProgram > loadProgram(const SurgSim::Framework::ApplicationData &data, const std::string &name)
Utility function, load a program from a set of shader files.
Definition: OsgProgram.cpp:217
Definition: OsgProgram.h:104
void setGlobalScope(bool val) override
When this is set to true, this shader should be used instead of other shaders that might apply,...
Definition: OsgProgram.cpp:134
std::array< osg::ref_ptr< osg::Shader >, SHADER_TYPE_COUNT > m_osgShaders
Storage of the osg objects.
Definition: OsgProgram.h:109
virtual bool getShaderSource(int shaderType, std::string *source) const
Gets the shader source code.
Definition: OsgProgram.cpp:187
bool getFragmentShaderSource(std::string *source) const override
Gets the fragment shader source code.
Definition: OsgProgram.cpp:124
bool getVertexShaderSource(std::string *source) const override
Gets the vertex shader source code.
Definition: OsgProgram.cpp:74
osg::ref_ptr< osg::Program > getOsgProgram() const
Definition: OsgProgram.cpp:129
bool isGlobalScope() const override
Query if this shader is of global scope.
Definition: OsgProgram.cpp:144
void setGeometryShaderSource(const std::string &source) override
Set the geometry shader source code.
Definition: OsgProgram.cpp:94
bool hasGeometryShader() const override
Definition: OsgProgram.cpp:79
Enable searching for files in a given list of paths, give access to the current directory and wrap bo...
Definition: ApplicationData.h:39
void removeFromStateSet(osg::StateSet *stateSet)
Removes this uniform from the OSG state set.
Definition: OsgProgram.cpp:46