![]() |
OSG-based implementation of a graphics shader. More...
#include <SurgSim/Graphics/OsgProgram.h>
Public Member Functions | |
OsgProgram () | |
Constructor. More... | |
bool | hasVertexShader () const override |
void | clearVertexShader () override |
Removes the vertex shader, returning that portion of the shader program to fixed-function. More... | |
bool | loadVertexShader (const std::string &filePath) override |
Loads the vertex shader source code from a file. More... | |
void | setVertexShaderSource (const std::string &source) override |
Set the vertex shader source code. More... | |
bool | getVertexShaderSource (std::string *source) const override |
Gets the vertex shader source code. More... | |
bool | hasGeometryShader () const override |
void | clearGeometryShader () override |
Removes the geometry shader, returning that portion of the shader program to fixed-function. More... | |
bool | loadGeometryShader (const std::string &filePath) override |
Loads the geometry shader source code from a file. More... | |
void | setGeometryShaderSource (const std::string &source) override |
Set the geometry shader source code. More... | |
bool | getGeometryShaderSource (std::string *source) const override |
Gets the geometry shader source code. More... | |
bool | hasFragmentShader () const override |
void | clearFragmentShader () override |
bool | loadFragmentShader (const std::string &filePath) override |
Loads the fragment shader source code from a file. More... | |
void | setFragmentShaderSource (const std::string &source) override |
Set the fragment shader source code. More... | |
bool | getFragmentShaderSource (std::string *source) const override |
Gets the fragment shader source code. More... | |
void | setGlobalScope (bool val) override |
When this is set to true, this shader should be used instead of other shaders that might apply, depending on the hierarchy that is set out. More... | |
bool | isGlobalScope () const override |
Query if this shader is of global scope. More... | |
osg::ref_ptr< osg::Program > | getOsgProgram () const |
void | addToStateSet (osg::StateSet *stateSet) |
Adds this shader to the OSG state set. More... | |
void | removeFromStateSet (osg::StateSet *stateSet) |
Removes this uniform from the OSG state set. More... | |
![]() | |
virtual | ~Program ()=0 |
Destructor. More... | |
virtual void | clear () |
Clears the entire shader, returning to fixed-function pipeline. More... | |
Private Types | |
enum | ShaderType { SHADER_TYPE_VERTEX = 0, SHADER_TYPE_FRAGMENT, SHADER_TYPE_GEOMETRY, SHADER_TYPE_COUNT } |
Private Member Functions | |
bool | hasShader (int shaderType) const |
Check whether there is a shader in use for the given type. More... | |
void | clearShader (int shaderType) |
Removes the geometry shader, returning that portion of the shader program to fixed-function. More... | |
bool | loadShaderSource (const std::string &filePath, int shaderType) |
Loads the shader source code from a file. More... | |
virtual void | setShaderSource (const std::string &source, int shaderType) |
Set the shader source code. More... | |
virtual bool | getShaderSource (int shaderType, std::string *source) const |
Gets the shader source code. More... | |
osg::ref_ptr< osg::Shader > | getOrCreateOsgShader (int shaderType) |
Fetches the appropriate shader if it exists, creates it otherwise. More... | |
Private Attributes | |
osg::ref_ptr< osg::Program > | m_program |
OSG program attribute. More... | |
std::array< osg::ref_ptr< osg::Shader >, SHADER_TYPE_COUNT > | m_osgShaders |
Storage of the osg objects. More... | |
bool | m_globalScope |
Is the shader supposed to be used globally. More... | |
OSG-based implementation of a graphics shader.
Wraps an osg::Program which manages the geometry, vertex, and fragment shaders. The osg::Program is added to the osg::StateSet of an osg::Node to use the shaders for the rendering of that node's geometry.
|
private |
SurgSim::Graphics::OsgProgram::OsgProgram | ( | ) |
Constructor.
void SurgSim::Graphics::OsgProgram::addToStateSet | ( | osg::StateSet * | stateSet | ) |
Adds this shader to the OSG state set.
stateSet | OSG state set |
|
overridevirtual |
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Removes the geometry shader, returning that portion of the shader program to fixed-function.
Implements SurgSim::Graphics::Program.
|
private |
Removes the geometry shader, returning that portion of the shader program to fixed-function.
shaderType | Type of the shader |
|
overridevirtual |
Removes the vertex shader, returning that portion of the shader program to fixed-function.
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Gets the fragment shader source code.
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Gets the geometry shader source code.
Implements SurgSim::Graphics::Program.
|
private |
Fetches the appropriate shader if it exists, creates it otherwise.
shaderType | Type of the shader |
osg::ref_ptr< osg::Program > SurgSim::Graphics::OsgProgram::getOsgProgram | ( | ) | const |
|
privatevirtual |
Gets the shader source code.
|
overridevirtual |
Gets the vertex shader source code.
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Implements SurgSim::Graphics::Program.
|
private |
Check whether there is a shader in use for the given type.
shaderType | Type of the shader |
|
overridevirtual |
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Query if this shader is of global scope.
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Loads the fragment shader source code from a file.
filePath | Path to file containing shader source code |
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Loads the geometry shader source code from a file.
filePath | Path to file containing shader source code |
Implements SurgSim::Graphics::Program.
|
private |
Loads the shader source code from a file.
filePath | Path to file containing shader source code |
shaderType | Type of the shader |
|
overridevirtual |
Loads the vertex shader source code from a file.
filePath | Path to file containing shader source code |
Implements SurgSim::Graphics::Program.
void SurgSim::Graphics::OsgProgram::removeFromStateSet | ( | osg::StateSet * | stateSet | ) |
Removes this uniform from the OSG state set.
stateSet | OSG state set |
|
overridevirtual |
Set the fragment shader source code.
source | Shader source code |
Implements SurgSim::Graphics::Program.
|
overridevirtual |
Set the geometry shader source code.
source | Shader source code |
Implements SurgSim::Graphics::Program.
|
overridevirtual |
When this is set to true, this shader should be used instead of other shaders that might apply, depending on the hierarchy that is set out.
E.g if this shader is on a camera, the shaders that occur in a group attached to that camera will be overridden. This will usually be used in conjunction with
val | If true the shader should override shaders in lower levels. |
Implements SurgSim::Graphics::Program.
|
privatevirtual |
Set the shader source code.
source | Shader source code |
shaderType | Type of the shader |
|
overridevirtual |
Set the vertex shader source code.
source | Shader source code |
Implements SurgSim::Graphics::Program.
|
private |
Is the shader supposed to be used globally.
|
private |
Storage of the osg objects.
|
private |
OSG program attribute.