#include <gl_frame_buffer_object.h>
Frame Buffer Object. This class encapsulates the frame buffer object (FBO) OpenGL spec. See the official spec at: http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt for details.
A frame buffer object (FBO) is conceptually a structure containing pointers to GPU memory. The memory pointed to is either an OpenGL texture or an OpenGL RenderBuffer. FBOs can be used to render to one or more textures, share depth buffers between multiple sets of color buffers/textures and are a complete replacement for pbuffers.
Performance Notes:
1) It is more efficient (but not required) to call bind() on an FBO before making multiple method calls.
2) Use FramebufferObject::disable() sparingly.
3) Binding an FBO is usually much faster than enabling/disabling a pbuffer, but is still a costly operation. When switching between multiple FBOs and a visible OpenGL framebuffer.
This implementation was inspired by the ideas in the FBO class from GPUGP by Aaron Lefohn.
OpenTissue::gl::FramebufferObject::FramebufferObject | ( | ) | [inline] |
OpenTissue::gl::FramebufferObject::~FramebufferObject | ( | ) | [inline] |
void OpenTissue::gl::FramebufferObject::attach_render_buffer | ( | GLenum | attachment, | |
GLuint | buffer_id | |||
) | [inline] |
Attach Render Buffer. This method binds a render buffer to the spcified "attachment" point of this FBO.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT However, this is usually GL_DEPTH_ATTACHMENT_EXT or GL_STENCIL_ATTACHMENT_EXT for depth and stencil buffers. | |
buffer_id | The identifier of the render buffer. That is the buffer name generated by calling glGenRenderbuffersEXT(...). |
void OpenTissue::gl::FramebufferObject::attach_render_buffer | ( | GLenum | attachment, | |
renderbuffer_pointer | buffer | |||
) | [inline] |
Attach Render Buffer. This method binds a render buffer to the spcified "attachment" point of this FBO.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT. However, this is usually GL_DEPTH_ATTACHMENT_EXT or GL_STENCIL_ATTACHMENT_EXT for depth and stencil buffers. | |
buffer | A pointer to a glRenderBuffer. |
void OpenTissue::gl::FramebufferObject::attach_texture | ( | GLenum | attachment, | |
GLenum | texture_target, | |||
GLuint | texture_id, | |||
int | mip_level = 0 , |
|||
int | z_slice = 0 | |||
) | [inline] |
Attach Texture. This method binds a texture to the specified "attachment" point of this FBO.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT | |
texture_target | The texture target: GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D etc.. | |
texture_id | The texture identifier, i.e the texture name as generated by calling the function glGenTextures(...). | |
mip_level | The level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. Default is zero. | |
z_slice | The z slice. This works as a z-offset into a 3D texture. The parameter is only used if texture target is a GL_TEXTURE_3D, the default value is zero. |
void OpenTissue::gl::FramebufferObject::attach_texture | ( | GLenum | attachment, | |
OpenTissue::texture::texture2D_pointer | texture | |||
) | [inline] |
Attach 2D Texture.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT | |
texture | A pointer to Texture2D containing the texture that should be attached. |
void OpenTissue::gl::FramebufferObject::attach_texture | ( | GLenum | attachment, | |
OpenTissue::texture::texture3D_pointer | texture, | |||
int | z_slice | |||
) | [inline] |
Attach 3D Texture.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT | |
texture | A pointer to Texture3D containing the texture that should be attached. |
void OpenTissue::gl::FramebufferObject::bind | ( | ) | [inline] |
Bind FBO. This method binds this FBO as current render target.
static GLuint OpenTissue::gl::FramebufferObject::create_fbo_id | ( | ) | [inline, static, protected] |
Create Frame Buffer Object Identifier.
static void OpenTissue::gl::FramebufferObject::disable | ( | ) | [inline, static] |
Disable FBO. Disable all FBO rendering and return to traditional, windowing-system controlled framebuffer. This is NOT an "unbind" for this specific FBO, but rather disables all FBO rendering.
Get Cube Face.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT |
Get Attachment Identifier.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT |
Get MipMap Level.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT |
Get Attachment Type.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT |
Get Z Slice.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT |
static GLint OpenTissue::gl::FramebufferObject::get_max_color_attachments | ( | ) | [inline, static] |
Get Maximum Color Attachments That is if GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENT(n-1)_EXT are valid attachment points then the number n is returned.
void OpenTissue::gl::FramebufferObject::guarded_bind | ( | ) | [inline, protected] |
Guarded Bind. This method tests whether this FBO is already bound. If not it will save the currently bound FBO before binding this FBO.
void OpenTissue::gl::FramebufferObject::guarded_unbind | ( | ) | [inline, protected] |
Guarded Unbind. In case another FBO was bound prior to invoking guarded_bind(), this method will restore that FBO.
bool OpenTissue::gl::FramebufferObject::is_valid | ( | std::ostream & | output = std::cerr |
) | [inline] |
Test if Frame Buffer Object is valid.
output | An output stream where error messages (if any) should be written. Default value is the std::cerr stream. |
void OpenTissue::gl::FramebufferObject::unattach | ( | GLenum | attachment | ) | [inline] |
Unattach Resources. This method frees any resource bound to the specified "attachment" point of this FBO.
attachment | The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT |
GLuint OpenTissue::gl::FramebufferObject::m_fbo_id [protected] |
The Frame buffer Identifier of this FBO.
The frame buffer identifier of any previously bound FBO. This is used to test whether the FBO is bound before doing anything to it. See guarded_bind and guarded_unbind.