OpenWalnut
1.5.0dev
|
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. More... | |
typedef osg::ref_ptr< const WGEOffscreenRenderPass > | ConstRefPtr |
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< WGETextureHud > | m_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... | |
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.
Definition at line 55 of file WGEOffscreenRenderPass.h.
typedef osg::ref_ptr< WGEOffscreenRenderPass > WGEOffscreenRenderPass::RefPtr |
Convenience typedef for an osg::ref_ptr.
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 206 of file WGEOffscreenRenderPass.cpp.
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.
buffer | the buffer to attach the new texture to |
internalFormat | the format to use. By default, RGBA |
Definition at line 95 of file WGEOffscreenRenderPass.cpp.
References attach(), createTexture(), and wlog::warn().
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.
buffer | the buffer to attach the texture to |
image | the image to attach |
Definition at line 90 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().
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 214 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 132 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 119 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 211 of file WGEOffscreenRenderPass.cpp.
Referenced by attach().
std::string WGEOffscreenRenderPass::getName | ( | ) | const |
Returns the name of this render pass.
Definition at line 191 of file WGEOffscreenRenderPass.cpp.
References m_name.
size_t WGEOffscreenRenderPass::getTextureHeight | ( | ) | const |
Get the size of the underlying texture.
Definition at line 201 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 196 of file WGEOffscreenRenderPass.cpp.
References m_width.
Referenced by WGEOffscreenTexturePass::TextureMatrixUpdateCallback::operator()().
|
protected |
The framebuffer object to use for this camera.
Definition at line 199 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 194 of file WGEOffscreenRenderPass.h.
Referenced by createTexture(), and getTextureHeight().
|
protected |
Gets notified about any added and removed attachment.
Definition at line 204 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 209 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 189 of file WGEOffscreenRenderPass.h.
Referenced by createTexture(), and getTextureWidth().