Workspace 6.21.5
|
Base class for all capabilities that can be added to a shader program. More...
#include <Rendering/OpenGL/Shaders/Capabilities/wsglshaderprogramcapability.h>
Public Types | |
enum | UsageFlags { UpdateOnActivate = 0x01 , UpdateOnRender = 0x02 , UpdatePerGlyph = 0x04 } |
Public Member Functions | |
virtual | ~WSGLShaderProgramCapability () |
virtual const WSGLShaderProgramCapabilityId & | capabilityId () const =0 |
virtual const CapabilityIdList & | dependencies () const =0 |
virtual QString | getSource (QOpenGLShader::ShaderType type) const =0 |
virtual UsageFlags | getUsageFlags () const =0 |
virtual bool | onProgramActivate (WSGLShaderProgram &program, WSGLRenderer &renderer)=0 |
virtual bool | onProgramDeactivate (WSGLShaderProgram &program, WSGLRenderer &renderer)=0 |
WSGLShaderProgramCapability & | operator= (const WSGLShaderProgramCapability &) |
virtual bool | postProgramLink (WSGLShaderProgram &program)=0 |
virtual bool | postRenderModel (WSGLShaderProgram &program, WSGLRenderer &renderer, WSGLRenderItem &item)=0 |
virtual bool | preRenderGlyph (WSGLShaderProgram &program, WSGLRenderer &renderer, WSGLInstancedItem &item, int instanceNumber)=0 |
virtual bool | preRenderModel (WSGLShaderProgram &program, WSGLRenderer &renderer, WSGLRenderItem &item)=0 |
Protected Member Functions | |
WSGLShaderProgramCapability () | |
WSGLShaderProgramCapability (const WSGLShaderProgramCapability &) | |
QString | readSourceFromFile (const QString &filename) const |
The WSGLRenderer uses a 'uber' shader model; that is, shaders share a common set of code and are built 'dynamically' when they are compiled in order to minimize the amount of code that a shader developer needs to write.
WSGLShaderImplementation objects are bound to a particular context, and each may instantiate multiple WSGLShaderPrograms. Each one of these programs corresponds to an OpenGL program object, with attached Vertex, Fragment and (potentially) Geometry shaders. In order to make use of commonly used WSGL capabilities such as lighting and transforms, the developer must add WSGLShaderProgramCapability objects to their WSGLShaderProgram. The program will then use these capabilities by invoking the relevant virtual functions at the correct times:
This allows the capability to differentiate between when a model is being rendered with glyphs on and the normal case, when it is rendered without glyphs.
enum UsageFlags |
|
protected |
|
protected |
|
virtual |
|
pure virtual |
Implemented in WSGLTypedShaderProgramCapability< Derived >, WSGLTypedShaderProgramCapability< WSGLBlinnPhongLightingCapability >, WSGLTypedShaderProgramCapability< WSGLClippingCapability >, WSGLTypedShaderProgramCapability< WSGLDepthPeelingCapability >, WSGLTypedShaderProgramCapability< WSGLLambertLightingCapability >, WSGLTypedShaderProgramCapability< WSGLScreenSpaceAmbientOcclusionCapability >, and WSGLTypedShaderProgramCapability< WSGLTransformCapability >.
|
pure virtual |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
pure virtual |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
pure virtual |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
pure virtual |
Invoked when the program is activated. The WSGLShaderProgram is assumed to be bound. Subclasses can override this function to set up any program or other GL state (such as uniform values) that do not change on a per-render-item basis.
program | The program which is being activated. |
renderer | The renderer on which the program is being activated. |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
pure virtual |
Invoked when the program is deactivated. The WSGLShaderProgram is assumed to be bound. Use this function to clean up any GL state that is common to all items rendered.
program | The program which is being deactivated. |
renderer | The renderer that the program is being deactivated on. |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
WSGLShaderProgramCapability & operator= | ( | const WSGLShaderProgramCapability & | rhs | ) |
rhs |
|
pure virtual |
Invoked immediately after the program is linked. Use this function to stored uniform locations or other variables which will remain constant for the life of the capability.
program | The program which has just been linked. |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
pure virtual |
Invoked immediately following the rendering of a WSGLRenderItem (i.e. immediately after a call to glDrawElements or glDrawRangeElements). Use this function to clean up any GL state that changes on a per-item basis. The program is assumed to be bound.
program | The program which is rendering the item. |
renderer | The renderer which the program has just used to render the item. |
item | The render item just drawn. |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
pure virtual |
Invoked immediately prior to the rendering of an individual glyph instance (i.e. immediately before a call to glDrawElements or glDrawRangeElements). Use this function to set up any GL state that changes on a per-glyph basis. The program is assumed to be bound.
program | The program which is rendering the item. |
renderer | The renderer which the program has just used to render the item. |
item | The instanced item we're going to use to render an instance. |
instanceNumber | The instance number of the glyph. |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
pure virtual |
Invoked immediately prior to the rendering of a WSGLRenderItem (i.e. immediately before a call to glDrawElements or glDrawRangeElements). Use this function to set up any GL state that changes on a per-item basis. The program is assumed to be bound.
program | The program which is rendering the item. |
renderer | The renderer which the program is about to use to render the item. |
item | The render item about to be drawn. |
Implemented in WSGLBlinnPhongLightingCapability, WSGLClippingCapability, WSGLDepthPeelingCapability, WSGLLambertLightingCapability, WSGLScreenSpaceAmbientOcclusionCapability, and WSGLTransformCapability.
|
protected |
filename | The name of the file from which the source is to be read. |