Workspace 6.21.5
Public Member Functions | Static Public Attributes | List of all members
WSGLScreenSpaceLayers Class Reference

Encapsulates the screen space layers used for rendering. More...

#include <Rendering/OpenGL/wsglscreenspacelayers.h>

Public Member Functions

 WSGLScreenSpaceLayers (int numLayers)
 
virtual ~WSGLScreenSpaceLayers ()
 
QOpenGLFramebufferObject & addExtraFramebufferObject (const QString &id, const QOpenGLFramebufferObjectFormat &format)
 
QOpenGLFramebufferObject & addExtraFramebufferObject (const QString &id, QOpenGLFramebufferObject::Attachment attachment)
 
bool bindLayer (int layerNumber)
 
void bindScreenFramebuffer ()
 
bool completeLayer (int layerNumber)
 
bool flattenLayers (Camera &camera, const Mesh::BoundingBox &sceneExtent)
 
const QColor & getBackgroundColor () const
 
const WSGLTexturegetCurrentDepthTexture () const
 
GLuint getCurrentLayerFboHandle () const
 
QOpenGLFramebufferObject * getExtraFramebufferObject (const QString &id)
 
bool getFaceCullingEnabled () const
 
bool getLayerCaptureEnabled () const
 
int getNumLayers ()
 
int getNumSamples ()
 
GLuint getScreenFramebufferHandle ()
 
WSGLScreenSpaceAmbientOcclusiongetScreenSpaceAmbientOcclusion ()
 
bool getSsaoEnabled () const
 
bool getSsaoSpecularEnabled () const
 
bool initialize (WSGLContext &context)
 
bool isInitialized () const
 
bool overlayFramebufferObject (const QOpenGLFramebufferObject &fbo)
 
bool overlayFullScreenTexture (GLuint textureId)
 
void releaseExtraFramebufferObject (const QString &id)
 
bool renderFullScreenEffect (WSGLShaderProgram &shader, GLuint transformUniformLocation, bool blend)
 
bool renderPlaceholderImage ()
 
bool resize ()
 
bool resizeRequired () const
 
void setBackgroundColor (const QColor &color)
 
void setFaceCullingEnabled (bool b)
 
bool setLayerCaptureEnabled (bool enable)
 
void setNumLayers (int numLayers)
 
void setNumSamples (int samples)
 
void setScreenFramebufferHandle (GLuint handle)
 
bool setSize (int viewportWidth, int viewportHeight)
 
void setSsaoEnabled (bool enable)
 
void setSsaoSpecularEnabled (bool enable)
 

Static Public Attributes

static const int MAX_DEPTH_LAYERS = 8
 
static const unsigned TEXCOORD_ATTRIB_LOCATION = 1
 
static const unsigned VERTEX_ATTRIB_LOCATION = 0
 

Detailed Description

The WSGLRenderer can do multiple passes of a Scene's geometry, writing the results to different 'layers' in screen space. Each of these layers can be used to achieve different effects, such as depth-peeling or screen-space-ambient-occlusion.

Constructor & Destructor Documentation

◆ WSGLScreenSpaceLayers()

WSGLScreenSpaceLayers ( int  numLayers)

◆ ~WSGLScreenSpaceLayers()

~WSGLScreenSpaceLayers ( )
virtual

Member Function Documentation

◆ addExtraFramebufferObject() [1/2]

QOpenGLFramebufferObject & addExtraFramebufferObject ( const QString &  id,
const QOpenGLFramebufferObjectFormat &  format 
)
Parameters
idThe unique identifier to associate with the framebuffer object.
format
Returns
The newly created framebuffer. If a framebuffer with the specified ID already exists, it will be returned. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ addExtraFramebufferObject() [2/2]

QOpenGLFramebufferObject & addExtraFramebufferObject ( const QString &  id,
QOpenGLFramebufferObject::Attachment  attachment 
)
Parameters
idThe unique identifier of the FBO to create.
attachmentThe type of buffers to attach to the new FBO
Returns
The newly created framebuffer. If a framebuffer with the specified ID already exists, it will be returned. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ bindLayer()

bool bindLayer ( int  layerNumber)

◆ bindScreenFramebuffer()

void bindScreenFramebuffer ( )

Binds the framebuffer being used as the screen.

◆ completeLayer()

bool completeLayer ( int  layerNumber)

◆ flattenLayers()

bool flattenLayers ( Camera camera,
const Mesh::BoundingBox sceneExtent 
)
Returns
True if the layers were successfully rendered, false otherwise.

◆ getBackgroundColor()

const QColor & getBackgroundColor ( ) const

◆ getCurrentDepthTexture()

const WSGLTexture * getCurrentDepthTexture ( ) const

◆ getCurrentLayerFboHandle()

GLuint getCurrentLayerFboHandle ( ) const
Returns
Returns a handle to the current layer's FBO. If there is only one layer, the "screen" fbo (by default, 0) will be returned.

◆ getExtraFramebufferObject()

QOpenGLFramebufferObject * getExtraFramebufferObject ( const QString &  id)

◆ getFaceCullingEnabled()

bool getFaceCullingEnabled ( ) const
Returns
True if face culling is enabled, false otherwise.

◆ getLayerCaptureEnabled()

bool getLayerCaptureEnabled ( ) const

◆ getNumLayers()

int getNumLayers ( )
Returns
The number of layers used during depth peeling.

◆ getNumSamples()

int getNumSamples ( )

◆ getScreenFramebufferHandle()

GLuint getScreenFramebufferHandle ( )
Returns
The handle being used as the frame buffer. May not necessarily be the main framebuffer; it could be another framebuffer object.

◆ getScreenSpaceAmbientOcclusion()

WSGLScreenSpaceAmbientOcclusion & getScreenSpaceAmbientOcclusion ( )

◆ getSsaoEnabled()

bool getSsaoEnabled ( ) const

◆ getSsaoSpecularEnabled()

bool getSsaoSpecularEnabled ( ) const

◆ initialize()

bool initialize ( WSGLContext context)

◆ isInitialized()

bool isInitialized ( ) const

◆ overlayFramebufferObject()

bool overlayFramebufferObject ( const QOpenGLFramebufferObject &  fbo)

◆ overlayFullScreenTexture()

bool overlayFullScreenTexture ( GLuint  textureId)
Parameters
textureIdThe ID of the texture to overlay. Is assumed to be screen sized.
Returns

◆ releaseExtraFramebufferObject()

void releaseExtraFramebufferObject ( const QString &  id)

◆ renderFullScreenEffect()

bool renderFullScreenEffect ( WSGLShaderProgram shader,
GLuint  transformUniformLocation,
bool  blend 
)

◆ renderPlaceholderImage()

bool renderPlaceholderImage ( )
Returns
true if the placeholder image was rendered successfully, false otherwise.

◆ resize()

bool resize ( )

◆ resizeRequired()

bool resizeRequired ( ) const
Returns
true if the WSGLScreenSpaceLayers object needs to have 'resize' called on it, false otherwise. This is likely due to a state change which has not yet been reflected on the object. For performance reasons, the object does not apply the state changes to its buffer data immediately.

◆ setBackgroundColor()

void setBackgroundColor ( const QColor &  color)

◆ setFaceCullingEnabled()

void setFaceCullingEnabled ( bool  b)
Parameters
bSet to true to notify the SSL class that face culling is enabled, false otherwise.

◆ setLayerCaptureEnabled()

bool setLayerCaptureEnabled ( bool  enable)

◆ setNumLayers()

void setNumLayers ( int  numLayers)
Parameters
numLayersThe number of layers to use when depth peeling.

◆ setNumSamples()

void setNumSamples ( int  samples)

◆ setScreenFramebufferHandle()

void setScreenFramebufferHandle ( GLuint  handle)
Parameters
handle

◆ setSize()

bool setSize ( int  viewportWidth,
int  viewportHeight 
)

◆ setSsaoEnabled()

void setSsaoEnabled ( bool  enable)

◆ setSsaoSpecularEnabled()

void setSsaoSpecularEnabled ( bool  enable)

Member Data Documentation

◆ MAX_DEPTH_LAYERS

const int MAX_DEPTH_LAYERS = 8
static

◆ TEXCOORD_ATTRIB_LOCATION

const unsigned TEXCOORD_ATTRIB_LOCATION = 1
static

◆ VERTEX_ATTRIB_LOCATION

const unsigned VERTEX_ATTRIB_LOCATION = 0
static