OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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:

Public Types

typedef osg::ref_ptr
< WGEOffscreenRenderPass
RefPtr
 Convenience typedef for an osg::ref_ptr.
typedef osg::ref_ptr< const
WGEOffscreenRenderPass
ConstRefPtr
 Convenience typedef for an osg::ref_ptr; const.

Public Member Functions

 WGEOffscreenRenderPass (size_t textureWidth, size_t textureHeight, int num=0)
 Creates a new offscreen rendering instance.
 WGEOffscreenRenderPass (size_t textureWidth, size_t textureHeight, osg::ref_ptr< WGETextureHud > hud, std::string name, int num=0)
 Creates a new offscreen rendering instance.
virtual ~WGEOffscreenRenderPass ()
 Destructor.
void attach (BufferComponent buffer, osg::ref_ptr< osg::Texture2D > texture)
 Attach a given texture to a buffer.
osg::ref_ptr< osg::Texture2D > attach (BufferComponent buffer, GLint internalFormat=GL_RGBA)
 This method attaches a texture to the given buffer.
void detach (BufferComponent buffer)
 Detaches the texture currently bound to the specified buffer.
template<typename T >
void bind (osg::ref_ptr< T > texture, size_t unit=0)
 This is a shortcut for wge::bindTexture.
osg::ref_ptr< osg::Texture2D > createTexture (GLint internalFormat=GL_RGBA)
 Creates a new texture suitable for this offscreen rendering instance.
std::string getName () const
 Returns the name of this render pass.
size_t getTextureWidth () const
 Get the size of the underlying texture.
size_t getTextureHeight () const
 Get the size of the underlying texture.
virtual void addUniform (osg::ref_ptr< osg::Uniform > uniform)
 The uniform to add.

Static Public Member Functions

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

Protected Attributes

size_t m_width
 The width of the textures used for this pass.
size_t m_height
 The height of the textures used for this pass.
osg::ref_ptr
< osg::FrameBufferObject > 
m_fbo
 The framebuffer object to use for this camera.
osg::ref_ptr< WGETextureHudm_hud
 Gets notified about any added and removed attachment.
std::string m_name
 The name if the rendering pass.

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

Convenience typedef for an osg::ref_ptr; const.

Definition at line 55 of file WGEOffscreenRenderPass.h.

Convenience typedef for an osg::ref_ptr.

Definition at line 50 of file WGEOffscreenRenderPass.h.

Constructor & Destructor Documentation

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::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 ( )
virtual

Destructor.

Definition at line 68 of file WGEOffscreenRenderPass.cpp.

Member Function Documentation

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 149 of file WGEOffscreenRenderPass.cpp.

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
Notes:
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().

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.

Parameters
bufferthe buffer to attach the new texture to
internalFormatthe format to use. By default, RGBA
Notes:
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 85 of file WGEOffscreenRenderPass.cpp.

References attach(), and createTexture().

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 202 of file WGEOffscreenRenderPass.h.

References wge::bindTexture().

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 117 of file WGEOffscreenRenderPass.cpp.

References m_height, and m_width.

Referenced by attach().

void WGEOffscreenRenderPass::detach ( BufferComponent  buffer)

Detaches the texture currently bound to the specified buffer.

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

Definition at line 104 of file WGEOffscreenRenderPass.cpp.

References m_fbo, and m_hud.

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 154 of file WGEOffscreenRenderPass.cpp.

Referenced by attach().

std::string WGEOffscreenRenderPass::getName ( ) const

Returns the name of this render pass.

Returns
the name

Definition at line 134 of file WGEOffscreenRenderPass.cpp.

References m_name.

size_t WGEOffscreenRenderPass::getTextureHeight ( ) const

Get the size of the underlying texture.

Returns
the height

Definition at line 144 of file WGEOffscreenRenderPass.cpp.

References m_height.

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

size_t WGEOffscreenRenderPass::getTextureWidth ( ) const

Get the size of the underlying texture.

Returns
the width

Definition at line 139 of file WGEOffscreenRenderPass.cpp.

References m_width.

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

Member Data Documentation

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

The framebuffer object to use for this camera.

Definition at line 187 of file WGEOffscreenRenderPass.h.

Referenced by attach(), and detach().

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 182 of file WGEOffscreenRenderPass.h.

Referenced by createTexture(), and getTextureHeight().

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

Gets notified about any added and removed attachment.

Definition at line 192 of file WGEOffscreenRenderPass.h.

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

std::string WGEOffscreenRenderPass::m_name
protected

The name if the rendering pass.

Especially useful in conjunction with m_hud.

Definition at line 197 of file WGEOffscreenRenderPass.h.

Referenced by attach(), and getName().

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 177 of file WGEOffscreenRenderPass.h.

Referenced by createTexture(), and getTextureWidth().


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