MeVisLab Toolbox Reference
SoGLShaderProgram Class Reference

Class managing an OpenGL shader program. More...

#include <SoGLShaderProgram.h>

Inheritance diagram for SoGLShaderProgram:
SoGLShader SoUniformParameterBase SoGLCompleteShader SoGLInventorShaderProgram

Classes

struct  UniformInfo
 Information structure for SoGLShaderObject containing location, type, and size. More...
 

Public Types

enum  LinkageResult { LR_FAILURE = 0 , LR_SUCCESS = 1 , LR_SKIPPED = 2 }
 
- Public Types inherited from SoUniformParameterBase
enum  SamplerType { SAMPLER_1D , SAMPLER_2D , SAMPLER_3D , SAMPLER_CUBEMAP }
 

Public Member Functions

 SoGLShaderProgram ()
 Constructor.
 
 ~SoGLShaderProgram () override
 Destructor.
 
void reset () override
 Free all resources (OpenGL too) and reset instance to initial state.
 
void addShaderObject (SoGLShaderObject *shaderObject)
 
void removeShaderObject (SoGLShaderObject *shaderObject)
 
void removeAllShaderObjects ()
 
void enable ()
 
void disable ()
 
void scheduleLinking ()
 
void setGeometryInputType (GLint type)
 
void setGeometryOutputType (GLint type)
 
void setGeometryVerticesOut (GLint number)
 
virtual void updateUniformsFromState (SoState *)
 Update the shader uniforms according to the current Inventor state.
 
virtual void preLinkSetup ()
 
virtual void postLinkSetup ()
 
virtual SbBool isActiveUniform (const SbString &name)
 
virtual void clearAssignedTextureUnits ()
 Clears the assigned texture units to 0.
 
int getNumAssignedTextureUnits ()
 
void setNumAssignedTextureUnits (int num)
 
int addTextureSampler (const SbString &name) override
 Adds a new texture sampler with given name and returns the assigned texture unit.
 
void set1f (const SbString &name, const float value) override
 
void set2f (const SbString &name, const float *value) override
 
void set3f (const SbString &name, const float *value) override
 
void set4f (const SbString &name, const float *value) override
 
void set2f (const SbString &name, const float value0, const float value1) override
 
void set3f (const SbString &name, const float value0, const float value1, const float value2) override
 
void set4f (const SbString &name, const float value0, const float value1, const float value2, const float value3) override
 
void set1fv (const SbString &name, const int num, const float *value) override
 
void set2fv (const SbString &name, const int num, const float *value) override
 
void set3fv (const SbString &name, const int num, const float *value) override
 
void set4fv (const SbString &name, const int num, const float *value) override
 
void set1i (const SbString &name, const int32_t value) override
 
void set2i (const SbString &name, const int32_t *value) override
 
void set2i (const SbString &name, const SbVec2s &value) override
 
void set3i (const SbString &name, const int32_t *value) override
 
void set3i (const SbString &name, const SbVec3s &value) override
 
void set4i (const SbString &name, const int32_t *value) override
 
void setMatrix3fv (const SbString &, int, const float *, SbBool=FALSE) override
 
void setMatrix4fv (const SbString &, int, const float *, SbBool=FALSE) override
 
void setName (const SbString &name)
 
const SbStringgetName () const
 
int shaderVersion (SoShader::ShaderType type) const
 Get the used GLSL version for the given shader type.
 
ml::GLSLProgram & getProgramResource ()
 
GLuint getProgramHandle () const
 
bool isValid ()
 returns if the shader is valid or needs re-creation
 
SbBool isExecutable () const
 
SbBool shouldLink () const
 
LinkageResult link ()
 
void updateUniformInfo (GLint programHandle)
 
void setAlwaysReadErrorLog (bool flag)
 
bool alwaysReadErrorLog ()
 
bool hadLinkError ()
 
const SbStringgetErrorLog ()
 
- Public Member Functions inherited from SoUniformParameterBase
virtual void setMatrix3f (const SbString &name, const float *values, SbBool transpose=FALSE)
 
virtual void setMatrix4f (const SbString &name, const float *values, SbBool transpose=FALSE)
 
virtual void setSamplerInfo (const SbString &, SamplerType, uint32_t)
 

Protected Member Functions

GLint getUniform (const SbString &name, GLenum type, int *num=nullptr)
 
- Protected Member Functions inherited from SoGLShader
 SoGLShader ()
 Constructor.
 
virtual ~SoGLShader ()
 Destructor.
 
void errClear (const char *string=nullptr) const
 Clear OpenGL error state and print any previously not displayed error message.
 
void errCheck (const char *string=nullptr) const
 Check for OpenGL errors and print error message if one is found.
 
SbBool error (const char *string=nullptr) const
 Returns 'TRUE' if OpenGL error is found.
 
- Protected Member Functions inherited from SoUniformParameterBase
 SoUniformParameterBase ()
 Hidden constructor.
 
virtual ~SoUniformParameterBase ()
 Hidden destructor.
 

Protected Attributes

ml::GLSLProgram _programRes
 
GLint _geometryInputType
 
GLint _geometryOutputType
 
GLint _geometryVerticesOut
 
std::list< SoGLShaderObject * > _shaderObjects
 
SbBool _shouldLink
 
SbBool _isExecutable
 
SbString _name
 
int _assignedTextureUnits
 
std::map< std::string, UniformInfo_uniformInfo
 
bool _alwaysReadErrorLog
 
bool _hadError
 
SbString _errorLog
 

Additional Inherited Members

- Static Public Member Functions inherited from SoGLShader
static SbBool isSupported ()
 Returns 'TRUE' if vertex and fragment shaders are supported by OpenGL.
 
static bool supportsGeometryShaders ()
 Returns if the hardware supports geometry shaders.
 
static void printCapabilities ()
 Prints capabilities of the OpenGL implementation.
 

Detailed Description

Class managing an OpenGL shader program.

Definition at line 32 of file SoGLShaderProgram.h.

Member Enumeration Documentation

◆ LinkageResult

Enumerator
LR_FAILURE 
LR_SUCCESS 
LR_SKIPPED 

Definition at line 123 of file SoGLShaderProgram.h.

Constructor & Destructor Documentation

◆ SoGLShaderProgram()

SoGLShaderProgram::SoGLShaderProgram ( )

Constructor.

◆ ~SoGLShaderProgram()

SoGLShaderProgram::~SoGLShaderProgram ( )
override

Destructor.

Member Function Documentation

◆ addShaderObject()

void SoGLShaderProgram::addShaderObject ( SoGLShaderObject * shaderObject)

◆ addTextureSampler()

int SoGLShaderProgram::addTextureSampler ( const SbString & name)
overridevirtual

Adds a new texture sampler with given name and returns the assigned texture unit.

Reimplemented from SoUniformParameterBase.

◆ alwaysReadErrorLog()

bool SoGLShaderProgram::alwaysReadErrorLog ( )
inline

Definition at line 153 of file SoGLShaderProgram.h.

◆ clearAssignedTextureUnits()

virtual void SoGLShaderProgram::clearAssignedTextureUnits ( )
inlinevirtual

Clears the assigned texture units to 0.

Definition at line 83 of file SoGLShaderProgram.h.

◆ disable()

void SoGLShaderProgram::disable ( )

◆ enable()

void SoGLShaderProgram::enable ( )

◆ getErrorLog()

const SbString & SoGLShaderProgram::getErrorLog ( )
inline

Definition at line 156 of file SoGLShaderProgram.h.

◆ getName()

const SbString & SoGLShaderProgram::getName ( ) const
inline

Definition at line 116 of file SoGLShaderProgram.h.

◆ getNumAssignedTextureUnits()

int SoGLShaderProgram::getNumAssignedTextureUnits ( )
inline

Definition at line 85 of file SoGLShaderProgram.h.

◆ getProgramHandle()

GLuint SoGLShaderProgram::getProgramHandle ( ) const
inline

Definition at line 133 of file SoGLShaderProgram.h.

◆ getProgramResource()

ml::GLSLProgram & SoGLShaderProgram::getProgramResource ( )
inline

Definition at line 129 of file SoGLShaderProgram.h.

◆ getUniform()

GLint SoGLShaderProgram::getUniform ( const SbString & name,
GLenum type,
int * num = nullptr )
protected

◆ hadLinkError()

bool SoGLShaderProgram::hadLinkError ( )
inline

Definition at line 155 of file SoGLShaderProgram.h.

◆ isActiveUniform()

virtual SbBool SoGLShaderProgram::isActiveUniform ( const SbString & name)
virtual

◆ isExecutable()

SbBool SoGLShaderProgram::isExecutable ( ) const
inline

Definition at line 140 of file SoGLShaderProgram.h.

◆ isValid()

bool SoGLShaderProgram::isValid ( )

returns if the shader is valid or needs re-creation

◆ link()

LinkageResult SoGLShaderProgram::link ( )

◆ postLinkSetup()

virtual void SoGLShaderProgram::postLinkSetup ( )
inlinevirtual

Reimplemented in SoGLInventorShaderProgram.

Definition at line 78 of file SoGLShaderProgram.h.

◆ preLinkSetup()

virtual void SoGLShaderProgram::preLinkSetup ( )
inlinevirtual

Reimplemented in SoGLInventorShaderProgram.

Definition at line 77 of file SoGLShaderProgram.h.

◆ removeAllShaderObjects()

void SoGLShaderProgram::removeAllShaderObjects ( )

◆ removeShaderObject()

void SoGLShaderProgram::removeShaderObject ( SoGLShaderObject * shaderObject)

◆ reset()

void SoGLShaderProgram::reset ( )
overridevirtual

Free all resources (OpenGL too) and reset instance to initial state.

Reimplemented from SoGLShader.

◆ scheduleLinking()

void SoGLShaderProgram::scheduleLinking ( )

◆ set1f()

void SoGLShaderProgram::set1f ( const SbString & name,
const float value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set1fv()

void SoGLShaderProgram::set1fv ( const SbString & name,
const int num,
const float * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set1i()

void SoGLShaderProgram::set1i ( const SbString & name,
const int32_t value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set2f() [1/2]

void SoGLShaderProgram::set2f ( const SbString & name,
const float * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set2f() [2/2]

void SoGLShaderProgram::set2f ( const SbString & name,
const float value0,
const float value1 )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set2fv()

void SoGLShaderProgram::set2fv ( const SbString & name,
const int num,
const float * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set2i() [1/2]

void SoGLShaderProgram::set2i ( const SbString & name,
const int32_t * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set2i() [2/2]

void SoGLShaderProgram::set2i ( const SbString & name,
const SbVec2s & value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set3f() [1/2]

void SoGLShaderProgram::set3f ( const SbString & name,
const float * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set3f() [2/2]

void SoGLShaderProgram::set3f ( const SbString & name,
const float value0,
const float value1,
const float value2 )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set3fv()

void SoGLShaderProgram::set3fv ( const SbString & name,
const int num,
const float * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set3i() [1/2]

void SoGLShaderProgram::set3i ( const SbString & name,
const int32_t * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set3i() [2/2]

void SoGLShaderProgram::set3i ( const SbString & name,
const SbVec3s & value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set4f() [1/2]

void SoGLShaderProgram::set4f ( const SbString & name,
const float * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set4f() [2/2]

void SoGLShaderProgram::set4f ( const SbString & name,
const float value0,
const float value1,
const float value2,
const float value3 )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set4fv()

void SoGLShaderProgram::set4fv ( const SbString & name,
const int num,
const float * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ set4i()

void SoGLShaderProgram::set4i ( const SbString & name,
const int32_t * value )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ setAlwaysReadErrorLog()

void SoGLShaderProgram::setAlwaysReadErrorLog ( bool flag)
inline

Definition at line 152 of file SoGLShaderProgram.h.

References mlrange_cast().

◆ setGeometryInputType()

void SoGLShaderProgram::setGeometryInputType ( GLint type)
inline

Definition at line 64 of file SoGLShaderProgram.h.

◆ setGeometryOutputType()

void SoGLShaderProgram::setGeometryOutputType ( GLint type)
inline

Definition at line 67 of file SoGLShaderProgram.h.

◆ setGeometryVerticesOut()

void SoGLShaderProgram::setGeometryVerticesOut ( GLint number)
inline

Definition at line 70 of file SoGLShaderProgram.h.

References mlrange_cast().

◆ setMatrix3fv()

void SoGLShaderProgram::setMatrix3fv ( const SbString & ,
int ,
const float * ,
SbBool = FALSE )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ setMatrix4fv()

void SoGLShaderProgram::setMatrix4fv ( const SbString & ,
int ,
const float * ,
SbBool = FALSE )
overridevirtual

Reimplemented from SoUniformParameterBase.

◆ setName()

void SoGLShaderProgram::setName ( const SbString & name)
inline

Definition at line 114 of file SoGLShaderProgram.h.

◆ setNumAssignedTextureUnits()

void SoGLShaderProgram::setNumAssignedTextureUnits ( int num)
inline

Definition at line 86 of file SoGLShaderProgram.h.

◆ shaderVersion()

int SoGLShaderProgram::shaderVersion ( SoShader::ShaderType type) const

Get the used GLSL version for the given shader type.

◆ shouldLink()

SbBool SoGLShaderProgram::shouldLink ( ) const
inline

Definition at line 144 of file SoGLShaderProgram.h.

◆ updateUniformInfo()

void SoGLShaderProgram::updateUniformInfo ( GLint programHandle)

◆ updateUniformsFromState()

virtual void SoGLShaderProgram::updateUniformsFromState ( SoState * )
inlinevirtual

Update the shader uniforms according to the current Inventor state.

To be reimplemented in derived classes.

Reimplemented in SoGLInventorShaderProgram.

Definition at line 76 of file SoGLShaderProgram.h.

Member Data Documentation

◆ _alwaysReadErrorLog

bool SoGLShaderProgram::_alwaysReadErrorLog
protected

Definition at line 180 of file SoGLShaderProgram.h.

◆ _assignedTextureUnits

int SoGLShaderProgram::_assignedTextureUnits
protected

Definition at line 166 of file SoGLShaderProgram.h.

◆ _errorLog

SbString SoGLShaderProgram::_errorLog
protected

Definition at line 182 of file SoGLShaderProgram.h.

◆ _geometryInputType

GLint SoGLShaderProgram::_geometryInputType
protected

Definition at line 40 of file SoGLShaderProgram.h.

◆ _geometryOutputType

GLint SoGLShaderProgram::_geometryOutputType
protected

Definition at line 41 of file SoGLShaderProgram.h.

◆ _geometryVerticesOut

GLint SoGLShaderProgram::_geometryVerticesOut
protected

Definition at line 42 of file SoGLShaderProgram.h.

◆ _hadError

bool SoGLShaderProgram::_hadError
protected

Definition at line 181 of file SoGLShaderProgram.h.

◆ _isExecutable

SbBool SoGLShaderProgram::_isExecutable
protected

Definition at line 162 of file SoGLShaderProgram.h.

◆ _name

SbString SoGLShaderProgram::_name
protected

Definition at line 164 of file SoGLShaderProgram.h.

◆ _programRes

ml::GLSLProgram SoGLShaderProgram::_programRes
protected

Definition at line 38 of file SoGLShaderProgram.h.

◆ _shaderObjects

std::list<SoGLShaderObject *> SoGLShaderProgram::_shaderObjects
protected

Definition at line 160 of file SoGLShaderProgram.h.

◆ _shouldLink

SbBool SoGLShaderProgram::_shouldLink
protected

Definition at line 161 of file SoGLShaderProgram.h.

◆ _uniformInfo

std::map<std::string, UniformInfo> SoGLShaderProgram::_uniformInfo
protected

Definition at line 176 of file SoGLShaderProgram.h.


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