Public Member Functions | Private Attributes | List of all members
SurgSim::Graphics::OsgShader Class Reference

OSG-based implementation of a graphics shader. More...

#include <SurgSim/Graphics/OsgShader.h>

Inheritance diagram for SurgSim::Graphics::OsgShader:
SurgSim::Graphics::Shader

Public Member Functions

 OsgShader ()
 Constructor. More...
 
virtual void addToStateSet (osg::StateSet *stateSet)
 Adds this shader to the OSG state set. More...
 
virtual void removeFromStateSet (osg::StateSet *stateSet)
 Removes this uniform from the OSG state set. More...
 
virtual bool hasVertexShader () const
 Returns true if the vertex shader has been set, otherwise false. More...
 
virtual void clearVertexShader ()
 Removes the vertex shader, returning that portion of the shader program to fixed-function. More...
 
virtual bool loadVertexShaderSource (const std::string &filePath)
 Loads the vertex shader source code from a file. More...
 
virtual void setVertexShaderSource (const std::string &source)
 Set the vertex shader source code. More...
 
virtual bool getVertexShaderSource (std::string *source) const
 Gets the vertex shader source code. More...
 
virtual bool hasGeometryShader () const
 Returns true if the geometry shader has been set, otherwise false. More...
 
virtual void clearGeometryShader ()
 Removes the geometry shader, returning that portion of the shader program to fixed-function. More...
 
virtual bool loadGeometryShaderSource (const std::string &filePath)
 Loads the geometry shader source code from a file. More...
 
virtual void setGeometryShaderSource (const std::string &source)
 Set the geometry shader source code. More...
 
virtual bool getGeometryShaderSource (std::string *source) const
 Gets the geometry shader source code. More...
 
virtual bool hasFragmentShader () const
 Returns true if the fragment shader has been set, otherwise false. More...
 
virtual void clearFragmentShader ()
 Removes the fragment shader, returning that portion of the shader program to fixed-function. More...
 
virtual bool loadFragmentShaderSource (const std::string &filePath)
 Loads the fragment shader source code from a file. More...
 
virtual void setFragmentShaderSource (const std::string &source)
 Set the fragment shader source code. More...
 
virtual bool getFragmentShaderSource (std::string *source) const
 Gets the fragment shader source code. More...
 
osg::ref_ptr< osg::Program > getOsgProgram () const
 Returns the OSG program attribute. More...
 
virtual void setGlobalScope (bool val) override
 Enables the shader to override other material shaders. More...
 
virtual bool isGlobalScope () const override
 Query if this object is global scope and overrides other lower level shaders. More...
 
- Public Member Functions inherited from SurgSim::Graphics::Shader
virtual ~Shader ()=0
 Destructor. More...
 
virtual void clear ()
 Clears the entire shader, returning to fixed-function pipeline. More...
 

Private Attributes

osg::ref_ptr< osg::Program > m_program
 OSG program attribute. More...
 
osg::ref_ptr< osg::Shader > m_vertexShader
 OSG vertex shader. More...
 
osg::ref_ptr< osg::Shader > m_geometryShader
 OSG geometry shader. More...
 
osg::ref_ptr< osg::Shader > m_fragmentShader
 OSG fragment shader. More...
 
bool m_globalScope
 Is the shader supposed to be used globally. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

OsgShader::OsgShader ( )

Constructor.

Postcondition
No shader code is set, so the fixed-function pipeline is used.

Member Function Documentation

void OsgShader::addToStateSet ( osg::StateSet *  stateSet)
virtual

Adds this shader to the OSG state set.

Parameters
stateSetOSG state set
void OsgShader::clearFragmentShader ( )
virtual

Removes the fragment shader, returning that portion of the shader program to fixed-function.

Implements SurgSim::Graphics::Shader.

void OsgShader::clearGeometryShader ( )
virtual

Removes the geometry shader, returning that portion of the shader program to fixed-function.

Implements SurgSim::Graphics::Shader.

void OsgShader::clearVertexShader ( )
virtual

Removes the vertex shader, returning that portion of the shader program to fixed-function.

Implements SurgSim::Graphics::Shader.

bool OsgShader::getFragmentShaderSource ( std::string *  source) const
virtual

Gets the fragment shader source code.

Returns
Shader source code

Implements SurgSim::Graphics::Shader.

bool OsgShader::getGeometryShaderSource ( std::string *  source) const
virtual

Gets the geometry shader source code.

Returns
Shader source code

Implements SurgSim::Graphics::Shader.

osg::ref_ptr< osg::Program > SurgSim::Graphics::OsgShader::getOsgProgram ( ) const

Returns the OSG program attribute.

bool OsgShader::getVertexShaderSource ( std::string *  source) const
virtual

Gets the vertex shader source code.

Returns
Shader source code

Implements SurgSim::Graphics::Shader.

bool OsgShader::hasFragmentShader ( ) const
virtual

Returns true if the fragment shader has been set, otherwise false.

Implements SurgSim::Graphics::Shader.

bool OsgShader::hasGeometryShader ( ) const
virtual

Returns true if the geometry shader has been set, otherwise false.

Implements SurgSim::Graphics::Shader.

bool OsgShader::hasVertexShader ( ) const
virtual

Returns true if the vertex shader has been set, otherwise false.

Implements SurgSim::Graphics::Shader.

bool SurgSim::Graphics::OsgShader::isGlobalScope ( ) const
overridevirtual

Query if this object is global scope and overrides other lower level shaders.

Returns
true if global scope, false if not.

Implements SurgSim::Graphics::Shader.

bool OsgShader::loadFragmentShaderSource ( const std::string &  filePath)
virtual

Loads the fragment shader source code from a file.

Parameters
filePathPath to file containing shader source code
Returns
True if the source is successfully loaded, otherwise false.

Implements SurgSim::Graphics::Shader.

bool OsgShader::loadGeometryShaderSource ( const std::string &  filePath)
virtual

Loads the geometry shader source code from a file.

Parameters
filePathPath to file containing shader source code
Returns
True if the source is successfully loaded, otherwise false.

Implements SurgSim::Graphics::Shader.

bool OsgShader::loadVertexShaderSource ( const std::string &  filePath)
virtual

Loads the vertex shader source code from a file.

Parameters
filePathPath to file containing shader source code
Returns
True if the source is successfully loaded, otherwise false.

Implements SurgSim::Graphics::Shader.

void OsgShader::removeFromStateSet ( osg::StateSet *  stateSet)
virtual

Removes this uniform from the OSG state set.

Parameters
stateSetOSG state set
void OsgShader::setFragmentShaderSource ( const std::string &  source)
virtual

Set the fragment shader source code.

Parameters
sourceShader source code

Implements SurgSim::Graphics::Shader.

void OsgShader::setGeometryShaderSource ( const std::string &  source)
virtual

Set the geometry shader source code.

Parameters
sourceShader source code

Implements SurgSim::Graphics::Shader.

void SurgSim::Graphics::OsgShader::setGlobalScope ( bool  val)
overridevirtual

Enables the shader to override other material shaders.

Parameters
valif true the shader will replace other shaders in a lower hierarchy.

Implements SurgSim::Graphics::Shader.

void OsgShader::setVertexShaderSource ( const std::string &  source)
virtual

Set the vertex shader source code.

Parameters
sourceShader source code

Implements SurgSim::Graphics::Shader.

Member Data Documentation

osg::ref_ptr<osg::Shader> SurgSim::Graphics::OsgShader::m_fragmentShader
private

OSG fragment shader.

osg::ref_ptr<osg::Shader> SurgSim::Graphics::OsgShader::m_geometryShader
private

OSG geometry shader.

bool SurgSim::Graphics::OsgShader::m_globalScope
private

Is the shader supposed to be used globally.

osg::ref_ptr<osg::Program> SurgSim::Graphics::OsgShader::m_program
private

OSG program attribute.

osg::ref_ptr<osg::Shader> SurgSim::Graphics::OsgShader::m_vertexShader
private

OSG vertex shader.


The documentation for this class was generated from the following files: