OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
WGEOffscreenRenderPass Class Reference

This class encapsulates an OSG Camera and a corresponding framebuffer object. More...

#include <WGEOffscreenRenderPass.h>

+ Inheritance diagram for WGEOffscreenRenderPass:
+ Collaboration diagram for WGEOffscreenRenderPass:

Public Types

typedef osg::ref_ptr< WGEOffscreenRenderPassRefPtr
 Convenience typedef for an osg::ref_ptr. More...
 
typedef osg::ref_ptr< const WGEOffscreenRenderPassConstRefPtr
 Convenience typedef for an osg::ref_ptr; const. More...
 
- Public Types inherited from WGECamera
enum  ProjectionMode { ORTHOGRAPHIC , PERSPECTIVE , TWO_D , TWO_D_UNIT }
 List of possible camera modes. More...
 

Public Member Functions

 WGEOffscreenRenderPass (size_t textureWidth, size_t textureHeight, int num=0)
 Creates a new offscreen rendering instance. More...
 
 WGEOffscreenRenderPass (size_t textureWidth, size_t textureHeight, osg::ref_ptr< WGETextureHud > hud, std::string name, int num=0)
 Creates a new offscreen rendering instance. More...
 
virtual ~WGEOffscreenRenderPass ()
 Destructor. More...
 
void attach (BufferComponent buffer, osg::ref_ptr< osg::Texture2D > texture)
 Attach a given texture to a buffer. More...
 
void attach (BufferComponent buffer, osg::ref_ptr< osg::Image > image)
 Attach a given image to a buffer. More...
 
osg::ref_ptr< osg::Texture2D > attach (BufferComponent buffer, GLint internalFormat=GL_RGBA)
 This method attaches a texture to the given buffer. More...
 
void detach (BufferComponent buffer)
 Detaches the texture currently bound to the specified buffer. More...
 
template<typename T >
void bind (osg::ref_ptr< T > texture, size_t unit=0)
 This is a shortcut for wge::bindTexture. More...
 
osg::ref_ptr< osg::Texture2D > createTexture (GLint internalFormat=GL_RGBA)
 Creates a new texture suitable for this offscreen rendering instance. More...
 
std::string getName () const
 Returns the name of this render pass. More...
 
size_t getTextureWidth () const
 Get the size of the underlying texture. More...
 
size_t getTextureHeight () const
 Get the size of the underlying texture. More...
 
virtual void addUniform (osg::ref_ptr< osg::Uniform > uniform)
 The uniform to add. More...
 
- Public Member Functions inherited from WGECamera
 WGECamera (int width, int height, ProjectionMode projectionMode)
 Constructor which sets defaults. More...
 
 WGECamera ()
 Constructor which sets defaults. More...
 
void setDefaultProjectionMode (ProjectionMode mode)
 Sets the default projection mode used for cameras getting reset. More...
 
ProjectionMode getDefaultProjectionMode ()
 Returns the current default projection mode. More...
 
void reset ()
 Resets the camera and activates the prior set defaults. More...
 
void resize ()
 Change camera parameters which should be changed on a resize. More...
 

Static Public Member Functions

static std::string getBufferName (BufferComponent buffer)
 Returns the buffer name. More...
 

Protected Attributes

size_t m_width
 The width of the textures used for this pass. More...
 
size_t m_height
 The height of the textures used for this pass. More...
 
osg::ref_ptr< osg::FrameBufferObject > m_fbo
 The framebuffer object to use for this camera. More...
 
osg::ref_ptr< WGETextureHudm_hud
 Gets notified about any added and removed attachment. More...
 
std::string m_name
 The name if the rendering pass. More...
 
- Protected Attributes inherited from WGECamera
ProjectionMode m_DefProjMode
 The projection mode used as default. More...
 

Additional Inherited Members

- Protected Member Functions inherited from WGECamera
virtual ~WGECamera ()
 Destructor. More...
 

Detailed Description

This class encapsulates an OSG Camera and a corresponding framebuffer object.

It is especially useful for offscreen renderings. It is a camera which, by default, is the same as the camera in the this instance nesting graph. It allows simple attachment of textures to a offscreen rendering as well as easy texture creation.

Definition at line 44 of file WGEOffscreenRenderPass.h.

Member Typedef Documentation

◆ ConstRefPtr

Convenience typedef for an osg::ref_ptr; const.

Definition at line 55 of file WGEOffscreenRenderPass.h.

◆ RefPtr

Convenience typedef for an osg::ref_ptr.

Definition at line 50 of file WGEOffscreenRenderPass.h.

Constructor & Destructor Documentation

◆ WGEOffscreenRenderPass() [1/2]

WGEOffscreenRenderPass::WGEOffscreenRenderPass ( size_t  textureWidth,
size_t  textureHeight,
int  num = 0 
)

Creates a new offscreen rendering instance.

Parameters
textureWidththe width of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size.
textureHeightthe height of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size.*
numthe order number. This camera gets rendered at the num'th place in the pre render queue of the subgraph it is attached to.

Definition at line 36 of file WGEOffscreenRenderPass.cpp.

◆ WGEOffscreenRenderPass() [2/2]

WGEOffscreenRenderPass::WGEOffscreenRenderPass ( size_t  textureWidth,
size_t  textureHeight,
osg::ref_ptr< WGETextureHud hud,
std::string  name,
int  num = 0 
)

Creates a new offscreen rendering instance.

Parameters
textureWidththe width of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size.
textureHeightthe height of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size.*
numthe order number. This camera gets rendered at the num'th place in the pre render queue of the subgraph it is attached to.
hudthe hud that gets notified about attached and detached textures. Useful for debugging.
namethe name of this render pass. This is a nice debugging feature in conjunction with WGETextureHud as it gets displayed there.

Definition at line 51 of file WGEOffscreenRenderPass.cpp.

◆ ~WGEOffscreenRenderPass()

WGEOffscreenRenderPass::~WGEOffscreenRenderPass ( )
virtual

Destructor.

Definition at line 68 of file WGEOffscreenRenderPass.cpp.

Member Function Documentation

◆ addUniform()

void WGEOffscreenRenderPass::addUniform ( osg::ref_ptr< osg::Uniform >  uniform)
virtual

The uniform to add.

This is a shortcut for this->getOrCreateStateSet()->addUniform( uniform ).

Parameters
uniformthe uniform to add

Definition at line 206 of file WGEOffscreenRenderPass.cpp.

◆ attach() [1/3]

osg::ref_ptr< osg::Texture2D > WGEOffscreenRenderPass::attach ( BufferComponent  buffer,
GLint  internalFormat = GL_RGBA 
)

This method attaches a texture to the given buffer.

The texture gets created with the resolution of the FBO.

On Mac OSX, only GL_RGBA works as internal format, so all input to internalFormat is ignored and overwritten by GL_RGBA internally.

Parameters
bufferthe buffer to attach the new texture to
internalFormatthe format to use. By default, RGBA
Note
if the node is added to the graph, these functions should only be called from within an update callback.
Returns
the newly created texture.

Definition at line 95 of file WGEOffscreenRenderPass.cpp.

References attach(), createTexture(), and wlog::warn().

+ Here is the call graph for this function:

◆ attach() [2/3]

void WGEOffscreenRenderPass::attach ( BufferComponent  buffer,
osg::ref_ptr< osg::Image >  image 
)

Attach a given image to a buffer.

Use this if you want to read back your rendered textures. This does not replace the attach call for textures. This only utilizes the multiple render target extension and allows you to read back your buffers.

Parameters
bufferthe buffer to attach the texture to
imagethe image to attach
Note
if the node is added to the graph, these functions should only be called from within an update callback.

Definition at line 90 of file WGEOffscreenRenderPass.cpp.

◆ attach() [3/3]

void WGEOffscreenRenderPass::attach ( BufferComponent  buffer,
osg::ref_ptr< osg::Texture2D >  texture 
)

Attach a given texture to a buffer.

Parameters
bufferthe buffer to attach the texture to
texturethe texture to attach
Note
if the node is added to the graph, these functions should only be called from within an update callback.

Definition at line 73 of file WGEOffscreenRenderPass.cpp.

References getBufferName(), m_fbo, m_hud, and m_name.

Referenced by attach().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bind()

template<typename T >
void WGEOffscreenRenderPass::bind ( osg::ref_ptr< T >  texture,
size_t  unit = 0 
)

This is a shortcut for wge::bindTexture.

See wge::bindTexture for details.

Parameters
unitthe unit to use
texturethe texture to use.
Template Parameters
Tthe type of texture. Usually osg::Texture3D or osg::Texture2D.

Definition at line 214 of file WGEOffscreenRenderPass.h.

References wge::bindTexture().

+ Here is the call graph for this function:

◆ createTexture()

osg::ref_ptr< osg::Texture2D > WGEOffscreenRenderPass::createTexture ( GLint  internalFormat = GL_RGBA)

Creates a new texture suitable for this offscreen rendering instance.

The texture will have the same size as the viewport of this camera.

Parameters
internalFormatthe format to use for the texture.
Returns
the newly created texture

Definition at line 132 of file WGEOffscreenRenderPass.cpp.

References m_height, and m_width.

Referenced by attach().

+ Here is the caller graph for this function:

◆ detach()

void WGEOffscreenRenderPass::detach ( BufferComponent  buffer)

Detaches the texture currently bound to the specified buffer.

Parameters
bufferthe buffer to detach.
Note
if the node is added to the graph, these functions should only be called from within an update callback.

Definition at line 119 of file WGEOffscreenRenderPass.cpp.

References m_fbo, and m_hud.

◆ getBufferName()

std::string WGEOffscreenRenderPass::getBufferName ( BufferComponent  buffer)
static

Returns the buffer name.

This is useful for debugging messages and so on as it maps a buffer constant to its name.

Parameters
bufferthe buffer to get the name for
Returns
the name

Definition at line 211 of file WGEOffscreenRenderPass.cpp.

Referenced by attach().

+ Here is the caller graph for this function:

◆ getName()

std::string WGEOffscreenRenderPass::getName ( ) const

Returns the name of this render pass.

Returns
the name

Definition at line 191 of file WGEOffscreenRenderPass.cpp.

References m_name.

◆ getTextureHeight()

size_t WGEOffscreenRenderPass::getTextureHeight ( ) const

Get the size of the underlying texture.

Returns
the height

Definition at line 201 of file WGEOffscreenRenderPass.cpp.

References m_height.

Referenced by WGEOffscreenTexturePass::TextureMatrixUpdateCallback::operator()().

+ Here is the caller graph for this function:

◆ getTextureWidth()

size_t WGEOffscreenRenderPass::getTextureWidth ( ) const

Get the size of the underlying texture.

Returns
the width

Definition at line 196 of file WGEOffscreenRenderPass.cpp.

References m_width.

Referenced by WGEOffscreenTexturePass::TextureMatrixUpdateCallback::operator()().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_fbo

osg::ref_ptr<osg::FrameBufferObject> WGEOffscreenRenderPass::m_fbo
protected

The framebuffer object to use for this camera.

Definition at line 199 of file WGEOffscreenRenderPass.h.

Referenced by attach(), and detach().

◆ m_height

size_t WGEOffscreenRenderPass::m_height
protected

The height of the textures used for this pass.

This should be as large as needed for each "common" viewport."

Definition at line 194 of file WGEOffscreenRenderPass.h.

Referenced by createTexture(), and getTextureHeight().

◆ m_hud

osg::ref_ptr< WGETextureHud > WGEOffscreenRenderPass::m_hud
protected

Gets notified about any added and removed attachment.

Definition at line 204 of file WGEOffscreenRenderPass.h.

Referenced by attach(), detach(), and WGEOffscreenFinalPass::WGEOffscreenFinalPass().

◆ m_name

std::string WGEOffscreenRenderPass::m_name
protected

The name if the rendering pass.

Especially useful in conjunction with m_hud.

Definition at line 209 of file WGEOffscreenRenderPass.h.

Referenced by attach(), and getName().

◆ m_width

size_t WGEOffscreenRenderPass::m_width
protected

The width of the textures used for this pass.

This should be as large as needed for each "common" viewport."

Definition at line 189 of file WGEOffscreenRenderPass.h.

Referenced by createTexture(), and getTextureWidth().


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