Open CASCADE Technology  7.4.0
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes

OpenGl_ShaderManager Class Reference

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

#include <OpenGl_ShaderManager.hxx>

Inheritance diagram for OpenGl_ShaderManager:
Inheritance graph
[legend]

Data Structures

struct  OpenGl_ShaderLightParameters
 Packed properties of light source. More...
 
struct  OpenGl_ShaderLightType
 Packed light source type information. More...
 
class  OpenGl_ShaderProgramFFP
 Fake OpenGL program for tracking FFP state in the way consistent to programmable pipeline. More...
 

Public Member Functions

 OpenGl_ShaderManager (OpenGl_Context *theContext)
 Creates new empty shader manager. More...
 
virtual ~OpenGl_ShaderManager ()
 Releases resources of shader manager. More...
 
void clear ()
 Release all resources. More...
 
const gp_XYZLocalOrigin () const
 Return local camera transformation. More...
 
void SetLocalOrigin (const gp_XYZ &theOrigin)
 Setup local camera transformation for compensating float precision issues. More...
 
Standard_Real LocalClippingPlaneW (const Graphic3d_ClipPlane &thePlane) const
 Return clipping plane W equation value moved considering local camera transformation. More...
 
Standard_Boolean Create (const Handle< Graphic3d_ShaderProgram > &theProxy, TCollection_AsciiString &theShareKey, Handle< OpenGl_ShaderProgram > &theProgram)
 Creates new shader program or re-use shared instance. More...
 
void Unregister (TCollection_AsciiString &theShareKey, Handle< OpenGl_ShaderProgram > &theProgram)
 Unregisters specified shader program. More...
 
const OpenGl_ShaderProgramListShaderPrograms () const
 Returns list of registered shader programs. More...
 
Standard_Boolean IsEmpty () const
 Returns true if no program objects are registered in the manager. More...
 
Standard_Boolean BindFaceProgram (const Handle< OpenGl_TextureSet > &theTextures, Graphic3d_TypeOfShadingModel theShadingModel, Graphic3d_AlphaMode theAlphaMode, Standard_Boolean theHasVertColor, Standard_Boolean theEnableEnvMap, const Handle< OpenGl_ShaderProgram > &theCustomProgram)
 Bind program for filled primitives rendering. More...
 
Standard_Boolean BindFaceProgram (const Handle< OpenGl_TextureSet > &theTextures, Graphic3d_TypeOfShadingModel theShadingModel, Graphic3d_AlphaMode theAlphaMode, Aspect_InteriorStyle theInteriorStyle, Standard_Boolean theHasVertColor, Standard_Boolean theEnableEnvMap, Standard_Boolean theEnableMeshEdges, const Handle< OpenGl_ShaderProgram > &theCustomProgram)
 Bind program for filled primitives rendering. More...
 
Standard_Boolean BindLineProgram (const Handle< OpenGl_TextureSet > &theTextures, const Aspect_TypeOfLine theLineType, const Graphic3d_TypeOfShadingModel theShadingModel, const Graphic3d_AlphaMode theAlphaMode, const Standard_Boolean theHasVertColor, const Handle< OpenGl_ShaderProgram > &theCustomProgram)
 Bind program for line rendering. More...
 
Standard_Boolean BindMarkerProgram (const Handle< OpenGl_TextureSet > &theTextures, Graphic3d_TypeOfShadingModel theShadingModel, Graphic3d_AlphaMode theAlphaMode, Standard_Boolean theHasVertColor, const Handle< OpenGl_ShaderProgram > &theCustomProgram)
 Bind program for point rendering. More...
 
Standard_Boolean BindFontProgram (const Handle< OpenGl_ShaderProgram > &theCustomProgram)
 Bind program for rendering alpha-textured font. More...
 
Standard_Boolean BindOutlineProgram ()
 Bind program for outline rendering. More...
 
Standard_Boolean BindFboBlitProgram ()
 Bind program for FBO blit operation. More...
 
Standard_Boolean BindOitCompositingProgram (const Standard_Boolean theIsMSAAEnabled)
 Bind program for blended order-independent transparency buffers compositing. More...
 
Standard_Boolean BindStereoProgram (const Graphic3d_StereoMode theStereoMode)
 Bind program for rendering stereoscopic image. More...
 
Standard_Boolean BindBoundBoxProgram ()
 Bind program for rendering bounding box. More...
 
const Handle< OpenGl_VertexBuffer > & BoundBoxVertBuffer () const
 Returns bounding box vertex buffer. More...
 
const Handle< Graphic3d_ShaderProgram > & GetBgCubeMapProgram ()
 Generates shader program to render environment cubemap as background. More...
 
const OpenGl_LightSourceStateLightSourceState () const
 Returns current state of OCCT light sources. More...
 
void UpdateLightSourceStateTo (const Handle< Graphic3d_LightSet > &theLights)
 Updates state of OCCT light sources. More...
 
void UpdateLightSourceState ()
 Invalidate state of OCCT light sources. More...
 
void PushLightSourceState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT light sources to specified program (only on state change). More...
 
void pushLightSourceState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT light sources to specified program. More...
 
const OpenGl_ProjectionStateProjectionState () const
 Returns current state of OCCT projection transform. More...
 
void UpdateProjectionStateTo (const OpenGl_Mat4 &theProjectionMatrix)
 Updates state of OCCT projection transform. More...
 
void PushProjectionState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT projection transform to specified program (only on state change). More...
 
void pushProjectionState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT projection transform to specified program. More...
 
const OpenGl_ModelWorldStateModelWorldState () const
 Returns current state of OCCT model-world transform. More...
 
void UpdateModelWorldStateTo (const OpenGl_Mat4 &theModelWorldMatrix)
 Updates state of OCCT model-world transform. More...
 
void PushModelWorldState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT model-world transform to specified program (only on state change). More...
 
void pushModelWorldState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT model-world transform to specified program. More...
 
const OpenGl_WorldViewStateWorldViewState () const
 Returns current state of OCCT world-view transform. More...
 
void UpdateWorldViewStateTo (const OpenGl_Mat4 &theWorldViewMatrix)
 Updates state of OCCT world-view transform. More...
 
void PushWorldViewState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT world-view transform to specified program (only on state change). More...
 
void pushWorldViewState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT world-view transform to specified program. More...
 
void UpdateClippingState ()
 Updates state of OCCT clipping planes. More...
 
void RevertClippingState ()
 Reverts state of OCCT clipping planes. More...
 
void PushClippingState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT clipping planes to specified program (only on state change). More...
 
void pushClippingState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT clipping planes to specified program. More...
 
const OpenGl_MaterialStateMaterialState () const
 Returns current state of material. More...
 
void UpdateMaterialStateTo (const OpenGl_Material &theFrontMat, const OpenGl_Material &theBackMat, const float theAlphaCutoff, const bool theToDistinguish, const bool theToMapTexture)
 Updates state of material. More...
 
void UpdateMaterialState ()
 Updates state of material. More...
 
void PushMaterialState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of material to specified program (only on state change). More...
 
void pushMaterialState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of material to specified program. More...
 
void PushInteriorState (const Handle< OpenGl_ShaderProgram > &theProgram, const Handle< Graphic3d_Aspects > &theAspect) const
 Setup interior style line edges variables. More...
 
const OpenGl_OitStateOitState () const
 Returns state of OIT uniforms. More...
 
void SetOitState (const bool theToEnableOitWrite, const float theDepthFactor)
 Set the state of OIT rendering pass (only on state change). More...
 
void PushOitState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes state of OIT uniforms to the specified program. More...
 
void pushOitState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes state of OIT uniforms to the specified program. More...
 
void PushState (const Handle< OpenGl_ShaderProgram > &theProgram) const
 Pushes current state of OCCT graphics parameters to specified program. More...
 
void SetContext (OpenGl_Context *theCtx)
 Overwrites context. More...
 
bool IsSameContext (OpenGl_Context *theCtx) const
 Returns true when provided context is the same as used one by shader manager. More...
 
Graphic3d_TypeOfShadingModel ChooseFaceShadingModel (Graphic3d_TypeOfShadingModel theCustomModel, bool theHasNodalNormals) const
 Choose Shading Model for filled primitives. Fallbacks to FACET model if there are no normal attributes. More...
 
Graphic3d_TypeOfShadingModel ChooseLineShadingModel (Graphic3d_TypeOfShadingModel theCustomModel, bool theHasNodalNormals) const
 Choose Shading Model for line primitives. Fallbacks to UNLIT model if there are no normal attributes. More...
 
Graphic3d_TypeOfShadingModel ChooseMarkerShadingModel (Graphic3d_TypeOfShadingModel theCustomModel, bool theHasNodalNormals) const
 Choose Shading Model for Marker primitives. More...
 
Graphic3d_TypeOfShadingModel ShadingModel () const
 Returns default Shading Model. More...
 
void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel)
 Sets shading model. More...
 
void SetLastView (const OpenGl_View *theLastView)
 Sets last view manger used with. Helps to handle matrix states in multi-view configurations. More...
 
bool IsSameView (const OpenGl_View *theView) const
 Returns true when provided view is the same as cached one. 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 opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::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 opencascade::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...
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Protected Member Functions

Standard_Integer getClipPlaneBits () const
 Define clipping planes program bits. More...
 
Standard_Integer getProgramBits (const Handle< OpenGl_TextureSet > &theTextures, Graphic3d_AlphaMode theAlphaMode, Aspect_InteriorStyle theInteriorStyle, Standard_Boolean theHasVertColor, Standard_Boolean theEnableEnvMap, Standard_Boolean theEnableMeshEdges) const
 Define program bits. More...
 
Handle< OpenGl_ShaderProgram > & getStdProgram (Graphic3d_TypeOfShadingModel theShadingModel, Standard_Integer theBits)
 Prepare standard GLSL program. More...
 
TCollection_AsciiString pointSpriteAlphaSrc (Standard_Integer theBits)
 Prepare standard GLSL program for accessing point sprite alpha. More...
 
TCollection_AsciiString pointSpriteShadingSrc (const TCollection_AsciiString &theBaseColorSrc, Standard_Integer theBits)
 Prepare standard GLSL program for computing point sprite shading. More...
 
Standard_Boolean prepareStdProgramFont ()
 Prepare standard GLSL program for textured font. More...
 
Standard_Boolean prepareStdProgramFboBlit ()
 Prepare standard GLSL program for FBO blit operation. More...
 
Standard_Boolean prepareStdProgramOitCompositing (const Standard_Boolean theMsaa)
 Prepare standard GLSL programs for OIT compositing operation. More...
 
Standard_Boolean prepareStdProgramUnlit (Handle< OpenGl_ShaderProgram > &theProgram, Standard_Integer theBits, Standard_Boolean theIsOutline=false)
 Prepare standard GLSL program without lighting. More...
 
Standard_Boolean prepareStdProgramLight (Handle< OpenGl_ShaderProgram > &theProgram, Graphic3d_TypeOfShadingModel theShadingModel, Standard_Integer theBits)
 Prepare standard GLSL program with lighting. More...
 
Standard_Boolean prepareStdProgramGouraud (Handle< OpenGl_ShaderProgram > &theProgram, const Standard_Integer theBits)
 Prepare standard GLSL program with per-vertex lighting. More...
 
Standard_Boolean prepareStdProgramPhong (Handle< OpenGl_ShaderProgram > &theProgram, const Standard_Integer theBits, const Standard_Boolean theIsFlatNormal=false)
 Prepare standard GLSL program with per-pixel lighting. More...
 
TCollection_AsciiString stdComputeLighting (Standard_Integer &theNbLights, Standard_Boolean theHasVertColor)
 Define computeLighting GLSL function depending on current lights configuration. More...
 
Standard_Boolean bindProgramWithState (const Handle< OpenGl_ShaderProgram > &theProgram)
 Bind specified program to current context and apply state. More...
 
void switchLightPrograms ()
 Set pointer myLightPrograms to active lighting programs set from myMapOfLightPrograms. More...
 
Standard_Boolean prepareStdProgramStereo (Handle< OpenGl_ShaderProgram > &theProgram, const Graphic3d_StereoMode theStereoMode)
 Prepare standard GLSL program for stereoscopic image. More...
 
Standard_Boolean prepareStdProgramBoundBox ()
 Prepare standard GLSL program for bounding box. More...
 
Standard_Integer defaultGlslVersion (const Handle< Graphic3d_ShaderProgram > &theProgram, const TCollection_AsciiString &theName, Standard_Integer theBits, bool theUsesDerivates=false) const
 Prepare GLSL version header. More...
 
TCollection_AsciiString prepareGeomMainSrc (OpenGl_ShaderObject::ShaderVariableList &theUnifoms, OpenGl_ShaderObject::ShaderVariableList &theStageInOuts, Standard_Integer theBits)
 Prepare GLSL source for geometry shader according to parameters. More...
 
void addClippingPlane (Standard_Integer &thePlaneId, const Graphic3d_ClipPlane &thePlane, const Graphic3d_Vec4d &theEq, const Standard_Integer theChainFwd) const
 Append clipping plane definition to temporary buffers. More...
 

Protected Attributes

Handle< OpenGl_ShaderProgramFFPmyFfpProgram
 
Graphic3d_TypeOfShadingModel myShadingModel
 lighting shading model More...
 
OpenGl_ShaderProgramList myProgramList
 The list of shader programs. More...
 
Handle< OpenGl_SetOfShaderProgramsmyLightPrograms
 pointer to active lighting programs matrix More...
 
Handle< OpenGl_SetOfProgramsmyUnlitPrograms
 programs matrix without lighting More...
 
Handle< OpenGl_SetOfProgramsmyOutlinePrograms
 programs matrix without lighting for outline presentation More...
 
Handle< OpenGl_ShaderProgrammyFontProgram
 standard program for textured text More...
 
Handle< OpenGl_ShaderProgrammyBlitProgram
 standard program for FBO blit emulation More...
 
Handle< OpenGl_ShaderProgrammyBoundBoxProgram
 standard program for bounding box More...
 
Handle< OpenGl_ShaderProgrammyOitCompositingProgram [2]
 standard program for OIT compositing (default and MSAA). More...
 
OpenGl_MapOfShaderPrograms myMapOfLightPrograms
 map of lighting programs depending on lights configuration More...
 
Handle< Graphic3d_ShaderProgrammyBgCubeMapProgram
 program for background cubemap rendering More...
 
Handle< OpenGl_ShaderProgrammyStereoPrograms [Graphic3d_StereoMode_NB]
 standard stereo programs More...
 
Handle< OpenGl_VertexBuffermyBoundBoxVertBuffer
 bounding box vertex buffer More...
 
OpenGl_ContextmyContext
 OpenGL context. More...
 
OpenGl_ProjectionState myProjectionState
 State of OCCT projection transformation. More...
 
OpenGl_ModelWorldState myModelWorldState
 State of OCCT model-world transformation. More...
 
OpenGl_WorldViewState myWorldViewState
 State of OCCT world-view transformation. More...
 
OpenGl_ClippingState myClippingState
 State of OCCT clipping planes. More...
 
OpenGl_LightSourceState myLightSourceState
 State of OCCT light sources. More...
 
OpenGl_MaterialState myMaterialState
 State of Front and Back materials. More...
 
OpenGl_OitState myOitState
 State of OIT uniforms. More...
 
gp_XYZ myLocalOrigin
 local camera transformation More...
 
Standard_Boolean myHasLocalOrigin
 flag indicating that local camera transformation has been set More...
 
NCollection_Array1< OpenGl_ShaderLightTypemyLightTypeArray
 
NCollection_Array1< OpenGl_ShaderLightParametersmyLightParamsArray
 
NCollection_Array1< OpenGl_Vec4myClipPlaneArray
 
NCollection_Array1< OpenGl_Vec4dmyClipPlaneArrayFfp
 
NCollection_Array1< Standard_IntegermyClipChainArray
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

Detailed Description

This class is responsible for managing shader programs.

Constructor & Destructor Documentation

◆ OpenGl_ShaderManager()

OpenGl_ShaderManager::OpenGl_ShaderManager ( OpenGl_Context theContext)

Creates new empty shader manager.

◆ ~OpenGl_ShaderManager()

virtual OpenGl_ShaderManager::~OpenGl_ShaderManager ( )
virtual

Releases resources of shader manager.

Member Function Documentation

◆ addClippingPlane()

void OpenGl_ShaderManager::addClippingPlane ( Standard_Integer thePlaneId,
const Graphic3d_ClipPlane thePlane,
const Graphic3d_Vec4d theEq,
const Standard_Integer  theChainFwd 
) const
inlineprotected

Append clipping plane definition to temporary buffers.

◆ BindBoundBoxProgram()

Standard_Boolean OpenGl_ShaderManager::BindBoundBoxProgram ( )
inline

Bind program for rendering bounding box.

◆ BindFaceProgram() [1/2]

Standard_Boolean OpenGl_ShaderManager::BindFaceProgram ( const Handle< OpenGl_TextureSet > &  theTextures,
Graphic3d_TypeOfShadingModel  theShadingModel,
Graphic3d_AlphaMode  theAlphaMode,
Standard_Boolean  theHasVertColor,
Standard_Boolean  theEnableEnvMap,
const Handle< OpenGl_ShaderProgram > &  theCustomProgram 
)
inline

Bind program for filled primitives rendering.

◆ BindFaceProgram() [2/2]

Standard_Boolean OpenGl_ShaderManager::BindFaceProgram ( const Handle< OpenGl_TextureSet > &  theTextures,
Graphic3d_TypeOfShadingModel  theShadingModel,
Graphic3d_AlphaMode  theAlphaMode,
Aspect_InteriorStyle  theInteriorStyle,
Standard_Boolean  theHasVertColor,
Standard_Boolean  theEnableEnvMap,
Standard_Boolean  theEnableMeshEdges,
const Handle< OpenGl_ShaderProgram > &  theCustomProgram 
)
inline

Bind program for filled primitives rendering.

◆ BindFboBlitProgram()

Standard_Boolean OpenGl_ShaderManager::BindFboBlitProgram ( )
inline

Bind program for FBO blit operation.

◆ BindFontProgram()

Standard_Boolean OpenGl_ShaderManager::BindFontProgram ( const Handle< OpenGl_ShaderProgram > &  theCustomProgram)
inline

Bind program for rendering alpha-textured font.

◆ BindLineProgram()

Standard_Boolean OpenGl_ShaderManager::BindLineProgram ( const Handle< OpenGl_TextureSet > &  theTextures,
const Aspect_TypeOfLine  theLineType,
const Graphic3d_TypeOfShadingModel  theShadingModel,
const Graphic3d_AlphaMode  theAlphaMode,
const Standard_Boolean  theHasVertColor,
const Handle< OpenGl_ShaderProgram > &  theCustomProgram 
)
inline

Bind program for line rendering.

◆ BindMarkerProgram()

Standard_Boolean OpenGl_ShaderManager::BindMarkerProgram ( const Handle< OpenGl_TextureSet > &  theTextures,
Graphic3d_TypeOfShadingModel  theShadingModel,
Graphic3d_AlphaMode  theAlphaMode,
Standard_Boolean  theHasVertColor,
const Handle< OpenGl_ShaderProgram > &  theCustomProgram 
)

Bind program for point rendering.

◆ BindOitCompositingProgram()

Standard_Boolean OpenGl_ShaderManager::BindOitCompositingProgram ( const Standard_Boolean  theIsMSAAEnabled)
inline

Bind program for blended order-independent transparency buffers compositing.

◆ BindOutlineProgram()

Standard_Boolean OpenGl_ShaderManager::BindOutlineProgram ( )
inline

Bind program for outline rendering.

◆ bindProgramWithState()

Standard_Boolean OpenGl_ShaderManager::bindProgramWithState ( const Handle< OpenGl_ShaderProgram > &  theProgram)
protected

Bind specified program to current context and apply state.

◆ BindStereoProgram()

Standard_Boolean OpenGl_ShaderManager::BindStereoProgram ( const Graphic3d_StereoMode  theStereoMode)
inline

Bind program for rendering stereoscopic image.

◆ BoundBoxVertBuffer()

const Handle< OpenGl_VertexBuffer >& OpenGl_ShaderManager::BoundBoxVertBuffer ( ) const
inline

Returns bounding box vertex buffer.

◆ ChooseFaceShadingModel()

Graphic3d_TypeOfShadingModel OpenGl_ShaderManager::ChooseFaceShadingModel ( Graphic3d_TypeOfShadingModel  theCustomModel,
bool  theHasNodalNormals 
) const
inline

Choose Shading Model for filled primitives. Fallbacks to FACET model if there are no normal attributes.

◆ ChooseLineShadingModel()

Graphic3d_TypeOfShadingModel OpenGl_ShaderManager::ChooseLineShadingModel ( Graphic3d_TypeOfShadingModel  theCustomModel,
bool  theHasNodalNormals 
) const
inline

Choose Shading Model for line primitives. Fallbacks to UNLIT model if there are no normal attributes.

◆ ChooseMarkerShadingModel()

Graphic3d_TypeOfShadingModel OpenGl_ShaderManager::ChooseMarkerShadingModel ( Graphic3d_TypeOfShadingModel  theCustomModel,
bool  theHasNodalNormals 
) const
inline

Choose Shading Model for Marker primitives.

◆ clear()

void OpenGl_ShaderManager::clear ( )

Release all resources.

◆ Create()

Standard_Boolean OpenGl_ShaderManager::Create ( const Handle< Graphic3d_ShaderProgram > &  theProxy,
TCollection_AsciiString theShareKey,
Handle< OpenGl_ShaderProgram > &  theProgram 
)

Creates new shader program or re-use shared instance.

Parameters
theProxy[IN] program definition
theShareKey[OUT] sharing key
theProgram[OUT] OpenGL program
Returns
true on success

◆ defaultGlslVersion()

Standard_Integer OpenGl_ShaderManager::defaultGlslVersion ( const Handle< Graphic3d_ShaderProgram > &  theProgram,
const TCollection_AsciiString theName,
Standard_Integer  theBits,
bool  theUsesDerivates = false 
) const
protected

Prepare GLSL version header.

◆ GetBgCubeMapProgram()

const Handle< Graphic3d_ShaderProgram >& OpenGl_ShaderManager::GetBgCubeMapProgram ( )

Generates shader program to render environment cubemap as background.

◆ getClipPlaneBits()

Standard_Integer OpenGl_ShaderManager::getClipPlaneBits ( ) const
inlineprotected

Define clipping planes program bits.

◆ getProgramBits()

Standard_Integer OpenGl_ShaderManager::getProgramBits ( const Handle< OpenGl_TextureSet > &  theTextures,
Graphic3d_AlphaMode  theAlphaMode,
Aspect_InteriorStyle  theInteriorStyle,
Standard_Boolean  theHasVertColor,
Standard_Boolean  theEnableEnvMap,
Standard_Boolean  theEnableMeshEdges 
) const
inlineprotected

Define program bits.

◆ getStdProgram()

Handle< OpenGl_ShaderProgram >& OpenGl_ShaderManager::getStdProgram ( Graphic3d_TypeOfShadingModel  theShadingModel,
Standard_Integer  theBits 
)
inlineprotected

Prepare standard GLSL program.

◆ IsEmpty()

Standard_Boolean OpenGl_ShaderManager::IsEmpty ( ) const

Returns true if no program objects are registered in the manager.

◆ IsSameContext()

bool OpenGl_ShaderManager::IsSameContext ( OpenGl_Context theCtx) const
inline

Returns true when provided context is the same as used one by shader manager.

◆ IsSameView()

bool OpenGl_ShaderManager::IsSameView ( const OpenGl_View theView) const
inline

Returns true when provided view is the same as cached one.

◆ LightSourceState()

const OpenGl_LightSourceState& OpenGl_ShaderManager::LightSourceState ( ) const
inline

Returns current state of OCCT light sources.

◆ LocalClippingPlaneW()

Standard_Real OpenGl_ShaderManager::LocalClippingPlaneW ( const Graphic3d_ClipPlane thePlane) const
inline

Return clipping plane W equation value moved considering local camera transformation.

◆ LocalOrigin()

const gp_XYZ& OpenGl_ShaderManager::LocalOrigin ( ) const
inline

Return local camera transformation.

◆ MaterialState()

const OpenGl_MaterialState& OpenGl_ShaderManager::MaterialState ( ) const
inline

Returns current state of material.

◆ ModelWorldState()

const OpenGl_ModelWorldState& OpenGl_ShaderManager::ModelWorldState ( ) const
inline

Returns current state of OCCT model-world transform.

◆ OitState()

const OpenGl_OitState& OpenGl_ShaderManager::OitState ( ) const
inline

Returns state of OIT uniforms.

◆ pointSpriteAlphaSrc()

TCollection_AsciiString OpenGl_ShaderManager::pointSpriteAlphaSrc ( Standard_Integer  theBits)
protected

Prepare standard GLSL program for accessing point sprite alpha.

◆ pointSpriteShadingSrc()

TCollection_AsciiString OpenGl_ShaderManager::pointSpriteShadingSrc ( const TCollection_AsciiString theBaseColorSrc,
Standard_Integer  theBits 
)
protected

Prepare standard GLSL program for computing point sprite shading.

◆ prepareGeomMainSrc()

TCollection_AsciiString OpenGl_ShaderManager::prepareGeomMainSrc ( OpenGl_ShaderObject::ShaderVariableList theUnifoms,
OpenGl_ShaderObject::ShaderVariableList theStageInOuts,
Standard_Integer  theBits 
)
protected

Prepare GLSL source for geometry shader according to parameters.

◆ prepareStdProgramBoundBox()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramBoundBox ( )
protected

Prepare standard GLSL program for bounding box.

◆ prepareStdProgramFboBlit()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit ( )
protected

Prepare standard GLSL program for FBO blit operation.

◆ prepareStdProgramFont()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont ( )
protected

Prepare standard GLSL program for textured font.

◆ prepareStdProgramGouraud()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud ( Handle< OpenGl_ShaderProgram > &  theProgram,
const Standard_Integer  theBits 
)
protected

Prepare standard GLSL program with per-vertex lighting.

◆ prepareStdProgramLight()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramLight ( Handle< OpenGl_ShaderProgram > &  theProgram,
Graphic3d_TypeOfShadingModel  theShadingModel,
Standard_Integer  theBits 
)
inlineprotected

Prepare standard GLSL program with lighting.

◆ prepareStdProgramOitCompositing()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramOitCompositing ( const Standard_Boolean  theMsaa)
protected

Prepare standard GLSL programs for OIT compositing operation.

◆ prepareStdProgramPhong()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong ( Handle< OpenGl_ShaderProgram > &  theProgram,
const Standard_Integer  theBits,
const Standard_Boolean  theIsFlatNormal = false 
)
protected

Prepare standard GLSL program with per-pixel lighting.

Parameters
theIsFlatNormalwhen TRUE, the Vertex normals will be ignored and Face normal will be computed instead

◆ prepareStdProgramStereo()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo ( Handle< OpenGl_ShaderProgram > &  theProgram,
const Graphic3d_StereoMode  theStereoMode 
)
protected

Prepare standard GLSL program for stereoscopic image.

◆ prepareStdProgramUnlit()

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit ( Handle< OpenGl_ShaderProgram > &  theProgram,
Standard_Integer  theBits,
Standard_Boolean  theIsOutline = false 
)
protected

Prepare standard GLSL program without lighting.

◆ ProjectionState()

const OpenGl_ProjectionState& OpenGl_ShaderManager::ProjectionState ( ) const
inline

Returns current state of OCCT projection transform.

◆ PushClippingState()

void OpenGl_ShaderManager::PushClippingState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const
inline

Pushes current state of OCCT clipping planes to specified program (only on state change).

◆ pushClippingState()

void OpenGl_ShaderManager::pushClippingState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes current state of OCCT clipping planes to specified program.

◆ PushInteriorState()

void OpenGl_ShaderManager::PushInteriorState ( const Handle< OpenGl_ShaderProgram > &  theProgram,
const Handle< Graphic3d_Aspects > &  theAspect 
) const

Setup interior style line edges variables.

◆ PushLightSourceState()

void OpenGl_ShaderManager::PushLightSourceState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const
inline

Pushes current state of OCCT light sources to specified program (only on state change).

◆ pushLightSourceState()

void OpenGl_ShaderManager::pushLightSourceState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes current state of OCCT light sources to specified program.

◆ PushMaterialState()

void OpenGl_ShaderManager::PushMaterialState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const
inline

Pushes current state of material to specified program (only on state change).

◆ pushMaterialState()

void OpenGl_ShaderManager::pushMaterialState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes current state of material to specified program.

◆ PushModelWorldState()

void OpenGl_ShaderManager::PushModelWorldState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const
inline

Pushes current state of OCCT model-world transform to specified program (only on state change).

◆ pushModelWorldState()

void OpenGl_ShaderManager::pushModelWorldState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes current state of OCCT model-world transform to specified program.

◆ PushOitState()

void OpenGl_ShaderManager::PushOitState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const
inline

Pushes state of OIT uniforms to the specified program.

◆ pushOitState()

void OpenGl_ShaderManager::pushOitState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes state of OIT uniforms to the specified program.

◆ PushProjectionState()

void OpenGl_ShaderManager::PushProjectionState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const
inline

Pushes current state of OCCT projection transform to specified program (only on state change).

◆ pushProjectionState()

void OpenGl_ShaderManager::pushProjectionState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes current state of OCCT projection transform to specified program.

◆ PushState()

void OpenGl_ShaderManager::PushState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes current state of OCCT graphics parameters to specified program.

◆ PushWorldViewState()

void OpenGl_ShaderManager::PushWorldViewState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const
inline

Pushes current state of OCCT world-view transform to specified program (only on state change).

◆ pushWorldViewState()

void OpenGl_ShaderManager::pushWorldViewState ( const Handle< OpenGl_ShaderProgram > &  theProgram) const

Pushes current state of OCCT world-view transform to specified program.

◆ RevertClippingState()

void OpenGl_ShaderManager::RevertClippingState ( )

Reverts state of OCCT clipping planes.

◆ SetContext()

void OpenGl_ShaderManager::SetContext ( OpenGl_Context theCtx)
inline

Overwrites context.

◆ SetLastView()

void OpenGl_ShaderManager::SetLastView ( const OpenGl_View theLastView)
inline

Sets last view manger used with. Helps to handle matrix states in multi-view configurations.

◆ SetLocalOrigin()

void OpenGl_ShaderManager::SetLocalOrigin ( const gp_XYZ theOrigin)
inline

Setup local camera transformation for compensating float precision issues.

◆ SetOitState()

void OpenGl_ShaderManager::SetOitState ( const bool  theToEnableOitWrite,
const float  theDepthFactor 
)
inline

Set the state of OIT rendering pass (only on state change).

Parameters
theToEnableOitWrite[in] flag indicating whether the special output should be written for OIT algorithm.
theDepthFactor[in] the scalar factor of depth influence to the fragment's coverage.

◆ SetShadingModel()

void OpenGl_ShaderManager::SetShadingModel ( const Graphic3d_TypeOfShadingModel  theModel)

Sets shading model.

◆ ShaderPrograms()

const OpenGl_ShaderProgramList& OpenGl_ShaderManager::ShaderPrograms ( ) const

Returns list of registered shader programs.

◆ ShadingModel()

Graphic3d_TypeOfShadingModel OpenGl_ShaderManager::ShadingModel ( ) const
inline

Returns default Shading Model.

◆ stdComputeLighting()

TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting ( Standard_Integer theNbLights,
Standard_Boolean  theHasVertColor 
)
protected

Define computeLighting GLSL function depending on current lights configuration.

Parameters
theNbLights[out] number of defined light sources
theHasVertColor[in] flag to use getVertColor() instead of Ambient and Diffuse components of active material

◆ switchLightPrograms()

void OpenGl_ShaderManager::switchLightPrograms ( )
protected

Set pointer myLightPrograms to active lighting programs set from myMapOfLightPrograms.

◆ Unregister()

void OpenGl_ShaderManager::Unregister ( TCollection_AsciiString theShareKey,
Handle< OpenGl_ShaderProgram > &  theProgram 
)

Unregisters specified shader program.

◆ UpdateClippingState()

void OpenGl_ShaderManager::UpdateClippingState ( )

Updates state of OCCT clipping planes.

◆ UpdateLightSourceState()

void OpenGl_ShaderManager::UpdateLightSourceState ( )

Invalidate state of OCCT light sources.

◆ UpdateLightSourceStateTo()

void OpenGl_ShaderManager::UpdateLightSourceStateTo ( const Handle< Graphic3d_LightSet > &  theLights)

Updates state of OCCT light sources.

◆ UpdateMaterialState()

void OpenGl_ShaderManager::UpdateMaterialState ( )
inline

Updates state of material.

◆ UpdateMaterialStateTo()

void OpenGl_ShaderManager::UpdateMaterialStateTo ( const OpenGl_Material theFrontMat,
const OpenGl_Material theBackMat,
const float  theAlphaCutoff,
const bool  theToDistinguish,
const bool  theToMapTexture 
)
inline

Updates state of material.

◆ UpdateModelWorldStateTo()

void OpenGl_ShaderManager::UpdateModelWorldStateTo ( const OpenGl_Mat4 theModelWorldMatrix)

Updates state of OCCT model-world transform.

◆ UpdateProjectionStateTo()

void OpenGl_ShaderManager::UpdateProjectionStateTo ( const OpenGl_Mat4 theProjectionMatrix)

Updates state of OCCT projection transform.

◆ UpdateWorldViewStateTo()

void OpenGl_ShaderManager::UpdateWorldViewStateTo ( const OpenGl_Mat4 theWorldViewMatrix)

Updates state of OCCT world-view transform.

◆ WorldViewState()

const OpenGl_WorldViewState& OpenGl_ShaderManager::WorldViewState ( ) const
inline

Returns current state of OCCT world-view transform.

Field Documentation

◆ myBgCubeMapProgram

Handle< Graphic3d_ShaderProgram > OpenGl_ShaderManager::myBgCubeMapProgram
protected

program for background cubemap rendering

◆ myBlitProgram

Handle< OpenGl_ShaderProgram > OpenGl_ShaderManager::myBlitProgram
protected

standard program for FBO blit emulation

◆ myBoundBoxProgram

Handle< OpenGl_ShaderProgram > OpenGl_ShaderManager::myBoundBoxProgram
protected

standard program for bounding box

◆ myBoundBoxVertBuffer

Handle< OpenGl_VertexBuffer > OpenGl_ShaderManager::myBoundBoxVertBuffer
protected

bounding box vertex buffer

◆ myClipChainArray

NCollection_Array1<Standard_Integer> OpenGl_ShaderManager::myClipChainArray
mutableprotected

◆ myClippingState

OpenGl_ClippingState OpenGl_ShaderManager::myClippingState
protected

State of OCCT clipping planes.

◆ myClipPlaneArray

NCollection_Array1<OpenGl_Vec4> OpenGl_ShaderManager::myClipPlaneArray
mutableprotected

◆ myClipPlaneArrayFfp

NCollection_Array1<OpenGl_Vec4d> OpenGl_ShaderManager::myClipPlaneArrayFfp
mutableprotected

◆ myContext

OpenGl_Context* OpenGl_ShaderManager::myContext
protected

OpenGL context.

◆ myFfpProgram

Handle< OpenGl_ShaderProgramFFP > OpenGl_ShaderManager::myFfpProgram
protected

◆ myFontProgram

Handle< OpenGl_ShaderProgram > OpenGl_ShaderManager::myFontProgram
protected

standard program for textured text

◆ myHasLocalOrigin

Standard_Boolean OpenGl_ShaderManager::myHasLocalOrigin
protected

flag indicating that local camera transformation has been set

◆ myLightParamsArray

NCollection_Array1<OpenGl_ShaderLightParameters> OpenGl_ShaderManager::myLightParamsArray
mutableprotected

◆ myLightPrograms

Handle< OpenGl_SetOfShaderPrograms > OpenGl_ShaderManager::myLightPrograms
protected

pointer to active lighting programs matrix

◆ myLightSourceState

OpenGl_LightSourceState OpenGl_ShaderManager::myLightSourceState
protected

State of OCCT light sources.

◆ myLightTypeArray

NCollection_Array1<OpenGl_ShaderLightType> OpenGl_ShaderManager::myLightTypeArray
mutableprotected

◆ myLocalOrigin

gp_XYZ OpenGl_ShaderManager::myLocalOrigin
protected

local camera transformation

◆ myMapOfLightPrograms

OpenGl_MapOfShaderPrograms OpenGl_ShaderManager::myMapOfLightPrograms
protected

map of lighting programs depending on lights configuration

◆ myMaterialState

OpenGl_MaterialState OpenGl_ShaderManager::myMaterialState
protected

State of Front and Back materials.

◆ myModelWorldState

OpenGl_ModelWorldState OpenGl_ShaderManager::myModelWorldState
protected

State of OCCT model-world transformation.

◆ myOitCompositingProgram

Handle< OpenGl_ShaderProgram > OpenGl_ShaderManager::myOitCompositingProgram[2]
protected

standard program for OIT compositing (default and MSAA).

◆ myOitState

OpenGl_OitState OpenGl_ShaderManager::myOitState
protected

State of OIT uniforms.

◆ myOutlinePrograms

Handle< OpenGl_SetOfPrograms > OpenGl_ShaderManager::myOutlinePrograms
protected

programs matrix without lighting for outline presentation

◆ myProgramList

OpenGl_ShaderProgramList OpenGl_ShaderManager::myProgramList
protected

The list of shader programs.

◆ myProjectionState

OpenGl_ProjectionState OpenGl_ShaderManager::myProjectionState
protected

State of OCCT projection transformation.

◆ myShadingModel

Graphic3d_TypeOfShadingModel OpenGl_ShaderManager::myShadingModel
protected

lighting shading model

◆ myStereoPrograms

Handle< OpenGl_ShaderProgram > OpenGl_ShaderManager::myStereoPrograms[Graphic3d_StereoMode_NB]
protected

standard stereo programs

◆ myUnlitPrograms

Handle< OpenGl_SetOfPrograms > OpenGl_ShaderManager::myUnlitPrograms
protected

programs matrix without lighting

◆ myWorldViewState

OpenGl_WorldViewState OpenGl_ShaderManager::myWorldViewState
protected

State of OCCT world-view transformation.


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