OpenWalnut
1.2.5
|
This class encapsulates an OSG Camera and a corresponding framebuffer object. More...
#include <WGEOffscreenRenderPass.h>
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< WGETextureHud > | m_hud |
Gets notified about any added and removed attachment. | |
std::string | m_name |
The name if the rendering pass. |
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.
typedef osg::ref_ptr< const WGEOffscreenRenderPass > WGEOffscreenRenderPass::ConstRefPtr |
Convenience typedef for an osg::ref_ptr; const.
Reimplemented in WGEOffscreenFinalPass.
Definition at line 55 of file WGEOffscreenRenderPass.h.
typedef osg::ref_ptr< WGEOffscreenRenderPass > WGEOffscreenRenderPass::RefPtr |
Convenience typedef for an osg::ref_ptr.
Reimplemented in WGEOffscreenFinalPass.
Definition at line 50 of file WGEOffscreenRenderPass.h.
WGEOffscreenRenderPass::WGEOffscreenRenderPass | ( | size_t | textureWidth, |
size_t | textureHeight, | ||
int | num = 0 |
||
) |
Creates a new offscreen rendering instance.
textureWidth | the width of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size. |
textureHeight | the height of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size.* |
num | the 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.
textureWidth | the width of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size. |
textureHeight | the height of all the textures created and used by this render pass. This should be large enough for every reasonable viewport size.* |
num | the order number. This camera gets rendered at the num'th place in the pre render queue of the subgraph it is attached to. |
hud | the hud that gets notified about attached and detached textures. Useful for debugging. |
name | the 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.
|
virtual |
Destructor.
Definition at line 68 of file WGEOffscreenRenderPass.cpp.
|
virtual |
The uniform to add.
This is a shortcut for this->getOrCreateStateSet()->addUniform( uniform ).
uniform | the 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.
buffer | the buffer to attach the texture to |
texture | the texture to attach |
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.
buffer | the buffer to attach the new texture to |
internalFormat | the format to use. By default, RGBA |
Definition at line 85 of file WGEOffscreenRenderPass.cpp.
References attach(), and createTexture().
void WGEOffscreenRenderPass::bind | ( | osg::ref_ptr< T > | texture, |
size_t | unit = 0 |
||
) |
This is a shortcut for wge::bindTexture.
See wge::bindTexture for details.
unit | the unit to use |
texture | the texture to use. |
T | the 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.
internalFormat | the format to use for the 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.
buffer | the buffer to detach. |
Definition at line 104 of file WGEOffscreenRenderPass.cpp.
|
static |
Returns the buffer name.
This is useful for debugging messages and so on as it maps a buffer constant to its name.
buffer | the buffer to get the name for |
Definition at line 154 of file WGEOffscreenRenderPass.cpp.
Referenced by attach().
std::string WGEOffscreenRenderPass::getName | ( | ) | const |
Returns the name of this render pass.
Definition at line 134 of file WGEOffscreenRenderPass.cpp.
References m_name.
size_t WGEOffscreenRenderPass::getTextureHeight | ( | ) | const |
Get the size of the underlying texture.
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.
Definition at line 139 of file WGEOffscreenRenderPass.cpp.
References m_width.
Referenced by WGEOffscreenTexturePass::TextureMatrixUpdateCallback::operator()().
|
protected |
The framebuffer object to use for this camera.
Definition at line 187 of file WGEOffscreenRenderPass.h.
|
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().
|
protected |
Gets notified about any added and removed attachment.
Definition at line 192 of file WGEOffscreenRenderPass.h.
Referenced by attach(), detach(), and WGEOffscreenFinalPass::WGEOffscreenFinalPass().
|
protected |
The name if the rendering pass.
Especially useful in conjunction with m_hud.
Definition at line 197 of file WGEOffscreenRenderPass.h.
|
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().