Open CASCADE Technology  6.9.0
Public Types | Public Member Functions | Static Public Member Functions
Graphic3d_ShaderProgram Class Reference

This class is responsible for managing shader programs. More...

#include <Graphic3d_ShaderProgram.hxx>

Inheritance diagram for Graphic3d_ShaderProgram:
Inheritance graph
[legend]

Public Types

enum  ShaderName { ShaderName_UNKNOWN, ShaderName_Phong }
 The list of built-in GLSL programs. More...
 

Public Member Functions

 Graphic3d_ShaderProgram ()
 Creates new empty program object. More...
 
 Graphic3d_ShaderProgram (const Graphic3d_ShaderProgram::ShaderName theName)
 Creates program object from pre-defined shaders. Raises Standard_Failure exception if shader resources are unavailable. More...
 
virtual ~Graphic3d_ShaderProgram ()
 Releases resources of program object. More...
 
void Destroy () const
 Releases resources of program object. More...
 
virtual Standard_Boolean IsDone () const
 Checks if the program object is valid or not. More...
 
const TCollection_AsciiStringGetId () const
 Returns unique ID used to manage resource in graphic driver. More...
 
const TCollection_AsciiStringHeader () const
 Returns GLSL header (version code and extensions). More...
 
void SetHeader (const TCollection_AsciiString &theHeader)
 Setup GLSL header containing language version code and used extensions. Will be prepended to the very beginning of the source code. Example: More...
 
Standard_Boolean AttachShader (const Handle< Graphic3d_ShaderObject > &theShader)
 Attaches shader object to the program object. More...
 
Standard_Boolean DetachShader (const Handle< Graphic3d_ShaderObject > &theShader)
 Detaches shader object from the program object. More...
 
const Graphic3d_ShaderObjectListShaderObjects () const
 Returns list of attached shader objects. More...
 
const
Graphic3d_ShaderVariableList
Variables () const
 Returns list of custom uniform variables. More...
 
template<class T >
Standard_Boolean PushVariable (const TCollection_AsciiString &theName, const T &theValue)
 Pushes custom uniform variable to the program. More...
 
void ClearVariables ()
 Removes all custom uniform variables from the program. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const
Handle_Standard_Type & 
DynamicType () const
 Returns a type information object about this object. More...
 
Standard_Boolean IsInstance (const Handle_Standard_Type &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const Handle_Standard_Type &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
virtual Handle_Standard_Transient This () const
 Returns a Handle which references this object. Must never be called to objects created in stack. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 

Static Public Member Functions

static const
TCollection_AsciiString
ShadersFolder ()
 The path to GLSL programs determined from CSF_ShadersDirectory or CASROOT environment variables. More...
 

Detailed Description

This class is responsible for managing shader programs.

Member Enumeration Documentation

The list of built-in GLSL programs.

Enumerator
ShaderName_UNKNOWN 

undefined program

ShaderName_Phong 

per-pixel lighting (Phong shading)

Constructor & Destructor Documentation

Graphic3d_ShaderProgram::Graphic3d_ShaderProgram ( )

Creates new empty program object.

Graphic3d_ShaderProgram::Graphic3d_ShaderProgram ( const Graphic3d_ShaderProgram::ShaderName  theName)

Creates program object from pre-defined shaders. Raises Standard_Failure exception if shader resources are unavailable.

virtual Graphic3d_ShaderProgram::~Graphic3d_ShaderProgram ( )
virtual

Releases resources of program object.

Member Function Documentation

Standard_Boolean Graphic3d_ShaderProgram::AttachShader ( const Handle< Graphic3d_ShaderObject > &  theShader)

Attaches shader object to the program object.

void Graphic3d_ShaderProgram::ClearVariables ( )

Removes all custom uniform variables from the program.

void Graphic3d_ShaderProgram::Destroy ( ) const

Releases resources of program object.

Standard_Boolean Graphic3d_ShaderProgram::DetachShader ( const Handle< Graphic3d_ShaderObject > &  theShader)

Detaches shader object from the program object.

const TCollection_AsciiString& Graphic3d_ShaderProgram::GetId ( ) const
inline

Returns unique ID used to manage resource in graphic driver.

const TCollection_AsciiString& Graphic3d_ShaderProgram::Header ( ) const
inline

Returns GLSL header (version code and extensions).

virtual Standard_Boolean Graphic3d_ShaderProgram::IsDone ( ) const
virtual

Checks if the program object is valid or not.

template<class T >
Standard_Boolean Graphic3d_ShaderProgram::PushVariable ( const TCollection_AsciiString theName,
const T &  theValue 
)
inline

Pushes custom uniform variable to the program.

void Graphic3d_ShaderProgram::SetHeader ( const TCollection_AsciiString theHeader)
inline

Setup GLSL header containing language version code and used extensions. Will be prepended to the very beginning of the source code. Example:

#version 300 es
#extension GL_ARB_bindless_texture : require
const Graphic3d_ShaderObjectList& Graphic3d_ShaderProgram::ShaderObjects ( ) const
inline

Returns list of attached shader objects.

static const TCollection_AsciiString& Graphic3d_ShaderProgram::ShadersFolder ( )
static

The path to GLSL programs determined from CSF_ShadersDirectory or CASROOT environment variables.

Returns
the root folder with default GLSL programs.
const Graphic3d_ShaderVariableList& Graphic3d_ShaderProgram::Variables ( ) const
inline

Returns list of custom uniform variables.


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