Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes

OpenTissue::gl::FramebufferObject Class Reference

#include <gl_frame_buffer_object.h>

List of all members.

Public Member Functions

 FramebufferObject ()
 ~FramebufferObject ()
void bind ()
void attach_texture (GLenum attachment, GLenum texture_target, GLuint texture_id, int mip_level=0, int z_slice=0)
void attach_texture (GLenum attachment, OpenTissue::texture::texture2D_pointer texture)
void attach_texture (GLenum attachment, OpenTissue::texture::texture3D_pointer texture, int z_slice)
void attach_render_buffer (GLenum attachment, GLuint buffer_id)
void attach_render_buffer (GLenum attachment, renderbuffer_pointer buffer)
void unattach (GLenum attachment)
bool is_valid (std::ostream &output=std::cerr)
GLenum get_attached_type (GLenum attachment)
GLuint get_attached_id (GLenum attachment)
GLint get_attached_mip_level (GLenum attachment)
GLint get_attached_cube_face (GLenum attachment)
GLint get_attached_Z_slice (GLenum attachment)

Static Public Member Functions

static GLint get_max_color_attachments ()
static void disable ()

Protected Member Functions

void guarded_bind ()
void guarded_unbind ()

Static Protected Member Functions

static GLuint create_fbo_id ()

Protected Attributes

GLuint m_fbo_id
 The Frame buffer Identifier of this FBO.
GLuint m_saved_fbo_id
 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.

Detailed Description

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.


Constructor & Destructor Documentation

OpenTissue::gl::FramebufferObject::FramebufferObject (  )  [inline]
OpenTissue::gl::FramebufferObject::~FramebufferObject (  )  [inline]

Member Function Documentation

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Returns:
A new unused identifier for a frame buffer object.
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.

GLint OpenTissue::gl::FramebufferObject::get_attached_cube_face ( GLenum  attachment  )  [inline]

Get Cube Face.

Parameters:
attachment The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT
Returns:
The cube face that is currently attached to specified attachment point.
GLuint OpenTissue::gl::FramebufferObject::get_attached_id ( GLenum  attachment  )  [inline]

Get Attachment Identifier.

Parameters:
attachment The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT
Returns:
The identifier of the of the render buffer/texture currently attached to specified attachement point.
GLint OpenTissue::gl::FramebufferObject::get_attached_mip_level ( GLenum  attachment  )  [inline]

Get MipMap Level.

Parameters:
attachment The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT
Returns:
The mipmap level that is currently attached to specified attachement point.
GLenum OpenTissue::gl::FramebufferObject::get_attached_type ( GLenum  attachment  )  [inline]

Get Attachment Type.

Parameters:
attachment The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT
Returns:
Returns the attached type, that is GL_RENDERBUFFER_EXT or GL_TEXTURE?
GLint OpenTissue::gl::FramebufferObject::get_attached_Z_slice ( GLenum  attachment  )  [inline]

Get Z Slice.

Parameters:
attachment The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT
Returns:
The z-slice that is currently attached to specified attachment point.
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.

Returns:
The number of color buffer attachments permitted.
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.

Parameters:
output An output stream where error messages (if any) should be written. Default value is the std::cerr stream.
Returns:
If the FBO is valid render target then the return value is true otherwise it is false. Notice that in non-debug build mode this function always return true.
void OpenTissue::gl::FramebufferObject::unattach ( GLenum  attachment  )  [inline]

Unattach Resources. This method frees any resource bound to the specified "attachment" point of this FBO.

Parameters:
attachment The attachment point. For instance the color buffer attachment point: GL_COLOR_ATTACHMENT0_EXT,...,GL_COLOR_ATTACHMENTn_EXT

Member Data Documentation

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.


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