opensurgsim
Public Member Functions | List of all members
SurgSim::Graphics::Program Class Referenceabstract

Base class that defines the interface for graphics programs. More...

#include <Program.h>

Inheritance diagram for SurgSim::Graphics::Program:
SurgSim::Framework::Asset SurgSim::Framework::Accessible SurgSim::Framework::FactoryBase< Asset > SurgSim::Graphics::MockProgram SurgSim::Graphics::OsgProgram

Public Member Functions

virtual ~Program ()=0
 Destructor.
 
virtual bool hasVertexShader () const =0
 
virtual void clearVertexShader ()=0
 Removes the vertex shader, returning that portion of the shader program to fixed-function.
 
virtual bool loadVertexShader (const std::string &filePath)=0
 Loads the vertex shader source code from a file. More...
 
virtual void setVertexShaderSource (const std::string &source)=0
 Set the vertex shader source code. More...
 
virtual bool getVertexShaderSource (std::string *source) const =0
 Gets the vertex shader source code. More...
 
virtual bool hasGeometryShader () const =0
 
virtual void clearGeometryShader ()=0
 Removes the geometry shader, returning that portion of the shader program to fixed-function.
 
virtual bool loadGeometryShader (const std::string &filePath)=0
 Loads the geometry shader source code from a file. More...
 
virtual void setGeometryShaderSource (const std::string &source)=0
 Set the geometry shader source code. More...
 
virtual bool getGeometryShaderSource (std::string *source) const =0
 Gets the geometry shader source code. More...
 
virtual bool hasFragmentShader () const =0
 
virtual void clearFragmentShader ()=0
 
virtual bool loadFragmentShader (const std::string &filePath)=0
 Loads the fragment shader source code from a file. More...
 
virtual void setFragmentShaderSource (const std::string &source)=0
 Set the fragment shader source code. More...
 
virtual bool getFragmentShaderSource (std::string *source) const =0
 Gets the fragment shader source code. More...
 
virtual void clear ()
 Clears the entire shader, returning to fixed-function pipeline.
 
virtual void setGlobalScope (bool val)=0
 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...
 
virtual bool isGlobalScope () const =0
 Query if this shader is of global scope. More...
 
- Public Member Functions inherited from SurgSim::Framework::Asset
 Asset ()
 Constructor.
 
 Asset (const Asset &rhs)
 Copy Constructor.
 
virtual ~Asset ()
 Destructor.
 
void load (const std::string &fileName, const SurgSim::Framework::ApplicationData &data)
 Load a file with given name using 'data' as look up path(s). More...
 
void load (const std::string &fileName)
 Overloaded function using SurgSim::Framework::Runtime::getApplicationData() as look up path(s). More...
 
std::string getFileName () const
 Return the name of file loaded by this class. More...
 
virtual std::string getClassName () const =0
 Support serialization with a classname. More...
 
- Public Member Functions inherited from SurgSim::Framework::Accessible
 Accessible ()
 Default Constructor.
 
 ~Accessible ()
 Destructor.
 
template<class T >
getValue (const std::string &name) const
 Retrieves the value with the name by executing the getter if it is found and tries to convert it to the given type. More...
 
boost::any getValue (const std::string &name) const
 Retrieves the value with the name by executing the getter if it is found. More...
 
template<class T >
bool getValue (const std::string &name, T *value) const
 Retrieves the value with the name by executing the getter if it is found, and converts it to the type of the output parameter. More...
 
void setValue (const std::string &name, const boost::any &value)
 Sets a value of a property that has setter. More...
 
bool isReadable (const std::string &name) const
 Check whether a property is readable. More...
 
bool isWriteable (const std::string &name) const
 Check whether a property is writable. More...
 
void setGetter (const std::string &name, GetterType func)
 Sets a getter for a given property. More...
 
void setSetter (const std::string &name, SetterType func)
 Sets a setter for a given property. More...
 
void setAccessors (const std::string &name, GetterType getter, SetterType setter)
 Sets the accessors getter and setter in one function. More...
 
void removeAccessors (const std::string &name)
 Removes all the accessors (getter and setter) for a given property. More...
 
void forwardProperty (const std::string &name, const Accessible &target, const std::string &targetProperty)
 Adds a property with the given name that uses the targets accessors, in effect forwarding the value to the target. More...
 
void setSerializable (const std::string &name, EncoderType encoder, DecoderType decoder)
 Sets the functions used to convert data from and to a YAML::Node. More...
 
void setDecoder (const std::string &name, DecoderType decoder)
 Sets the functions used to convert data from a YAML::Node. More...
 
YAML::Node encode () const
 Encode this Accessible to a YAML::Node. More...
 
void decode (const YAML::Node &node, const std::vector< std::string > &ignoredProperties=std::vector< std::string >())
 Decode this Accessible from a YAML::Node, will throw an exception if the data type cannot be converted. More...
 
std::vector< std::string > getProperties ()
 
template<>
boost::any getValue (const std::string &name) const
 

Additional Inherited Members

- Public Types inherited from SurgSim::Framework::Accessible
typedef std::function< boost::any(void)> GetterType
 
typedef std::function< void(boost::any)> SetterType
 
typedef std::function< YAML::Node(void)> EncoderType
 
typedef std::function< void(const YAML::Node *)> DecoderType
 
- Public Types inherited from SurgSim::Framework::FactoryBase< Asset >
typedef ObjectFactory< AssetFactoryType
 
- Static Public Member Functions inherited from SurgSim::Framework::FactoryBase< Asset >
static FactoryTypegetFactory ()
 
- Protected Member Functions inherited from SurgSim::Framework::Asset
virtual bool doLoad (const std::string &filePath)=0
 Derived classes will overwrite this method to do actual loading. More...
 

Detailed Description

Base class that defines the interface for graphics programs.

A program in OSS is a collection of 'shaders' that are usually executed in sequence (Geometry, Vertex and Fragment). Each shader itself is software that is executed on the GPU, shaders are usually introduced as source. The concept is similar to the use of program in OpenGL see https://www.opengl.org/sdk/docs/man4/html/glCreateProgram.xhtml

Member Function Documentation

§ clearFragmentShader()

virtual void SurgSim::Graphics::Program::clearFragmentShader ( )
pure virtual
Returns
the fragment shader, returning that portion of the shader program to fixed-function.

Implemented in SurgSim::Graphics::OsgProgram.

§ getFragmentShaderSource()

virtual bool SurgSim::Graphics::Program::getFragmentShaderSource ( std::string *  source) const
pure virtual

Gets the fragment shader source code.

Returns
Shader source code

Implemented in SurgSim::Graphics::OsgProgram.

§ getGeometryShaderSource()

virtual bool SurgSim::Graphics::Program::getGeometryShaderSource ( std::string *  source) const
pure virtual

Gets the geometry shader source code.

Returns
Shader source code

Implemented in SurgSim::Graphics::OsgProgram.

§ getVertexShaderSource()

virtual bool SurgSim::Graphics::Program::getVertexShaderSource ( std::string *  source) const
pure virtual

Gets the vertex shader source code.

Returns
Shader source code

Implemented in SurgSim::Graphics::OsgProgram.

§ hasFragmentShader()

virtual bool SurgSim::Graphics::Program::hasFragmentShader ( ) const
pure virtual
Returns
true if the fragment shader has been set, otherwise false.

Implemented in SurgSim::Graphics::OsgProgram.

§ hasGeometryShader()

virtual bool SurgSim::Graphics::Program::hasGeometryShader ( ) const
pure virtual
Returns
true if the geometry shader has been set, otherwise false.

Implemented in SurgSim::Graphics::OsgProgram.

§ hasVertexShader()

virtual bool SurgSim::Graphics::Program::hasVertexShader ( ) const
pure virtual
Returns
true if the vertex shader has been set, otherwise false.

Implemented in SurgSim::Graphics::OsgProgram.

§ isGlobalScope()

virtual bool SurgSim::Graphics::Program::isGlobalScope ( ) const
pure virtual

Query if this shader is of global scope.

Returns
true if global scope, false if not.

Implemented in SurgSim::Graphics::OsgProgram.

§ loadFragmentShader()

virtual bool SurgSim::Graphics::Program::loadFragmentShader ( const std::string &  filePath)
pure 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.

Implemented in SurgSim::Graphics::OsgProgram.

§ loadGeometryShader()

virtual bool SurgSim::Graphics::Program::loadGeometryShader ( const std::string &  filePath)
pure 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.

Implemented in SurgSim::Graphics::OsgProgram.

§ loadVertexShader()

virtual bool SurgSim::Graphics::Program::loadVertexShader ( const std::string &  filePath)
pure 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.

Implemented in SurgSim::Graphics::OsgProgram.

§ setFragmentShaderSource()

virtual void SurgSim::Graphics::Program::setFragmentShaderSource ( const std::string &  source)
pure virtual

Set the fragment shader source code.

Parameters
sourceShader source code

Implemented in SurgSim::Graphics::OsgProgram.

§ setGeometryShaderSource()

virtual void SurgSim::Graphics::Program::setGeometryShaderSource ( const std::string &  source)
pure virtual

Set the geometry shader source code.

Parameters
sourceShader source code

Implemented in SurgSim::Graphics::OsgProgram.

§ setGlobalScope()

virtual void SurgSim::Graphics::Program::setGlobalScope ( bool  val)
pure virtual

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

See also
RenderPass.
Parameters
valIf true the shader should override shaders in lower levels.

Implemented in SurgSim::Graphics::OsgProgram.

§ setVertexShaderSource()

virtual void SurgSim::Graphics::Program::setVertexShaderSource ( const std::string &  source)
pure virtual

Set the vertex shader source code.

Parameters
sourceShader source code

Implemented in SurgSim::Graphics::OsgProgram.


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