# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Public Attributes | Friends

# vl::FBORenderTarget Class Reference

Implements a framebuffer object to be used as a rendering target as specified by the `ARB_framebuffer_object` extension. More...

`#include <FramebufferObject.hpp>`

Inheritance diagram for vl::FBORenderTarget:

List of all members.

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| ~FBORenderTarget ()
| Destructor.
void | create ()
| Creates a framebuffer object by calling glGenFramebuffers().
void | destroy ()
| Deletes a framebuffer object by calling glDeleteFramebuffers().
void | setHandle (GLuint handle)
| The handle of the framebuffer object as returned by glGenFramebuffers.
virtual GLuint | handle () const
| The handle of the framebuffer object as returned by glGenFramebuffers.
virtual void | bindFramebuffer (EFrameBufferBind target=FBB_FRAMEBUFFER)
| Makes the framebuffer the current rendering target calling glBindFramebuffer( GL_FRAMEBUFFER, FBORenderTarget::handle() ) and initializes all the previously defined attachment points.
GLenum | checkFramebufferStatus ()
| Checks the framebuffer status and returns the value of glCheckFramebufferStatus()
void | printFramebufferError (GLenum status) const
| Prints a human readable description of the error code as returned by glCheckFramebufferStatus()
void | addColorAttachment (EAttachmentPoint attach_point, FBOColorBufferAttachment *attachment)
| Binds a color attachment to a framebuffer object.
void | addTextureAttachment (EAttachmentPoint attach_point, FBOAbstractTextureAttachment *attachment)
| Binds a texture attachment to a framebuffer object.
void | addDepthAttachment (FBOAbstractAttachment *attachment)
| Binds a depth attachment to a framebuffer object.
void | addStencilAttachment (FBOAbstractAttachment *attachment)
| Binds a stencil attachment to a framebuffer object.
void | addDepthStencilAttachment (FBOAbstractAttachment *attachment)
| Binds a depth-stencil attachment to a framebuffer object.
void | removeAttachment (FBOAbstractAttachment *attachment)
| Unbinds the given attachments from a framebuffer object.
void | removeAttachment (EAttachmentPoint attach_point)
| Unbinds the attachment associated to the given attachment point from a framebuffer object.
void | removeAllAttachments ()
| Unbinds all attachments bound to a framebuffer object.
const std::map < EAttachmentPoint, ref < FBOAbstractAttachment > > & | fboAttachments () const
| A map associating which fbo-attachment belongs to which attachment point in a framebuffer object.

## Public Attributes

std::map< EAttachmentPoint, ref< FBOAbstractAttachment > > | mFBOAttachments
GLuint | mHandle

## Friends

class | OpenGLContext

## Detailed Description

Implements a framebuffer object to be used as a rendering target as specified by the `ARB_framebuffer_object` extension.

An FBORenderTarget belongs to one and only one OpenGLContext and can be created using the OpenGLContext::createFBORenderTarget() method. To render to a FBORenderTarget use the Rendering::setRenderTarget() function.

Remarks:
  Before using any method from FBORenderTarget make sure that the appropriate OpenGL rendering context is active using FBORenderTarget::openglContext()->makeCurrent()
  All the renderbuffer attachments must specify the same number of samples.

See also:
  - Framebuffer Objects Tutorial
  - `ARB_framebuffer_object` specifications http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt
  - FBORenderbufferAttachment
  - FBOColorBufferAttachment
  - FBODepthBufferAttachment
  - FBODepthStencilBufferAttachment
  - FBOStencilBufferAttachment
  - FBOTexture1DAttachment
  - FBOTexture2DAttachment
  - FBOTexture3DAttachment
  - FBOTextureAttachment
  - FBOTextureLayerAttachment

Definition at line 503 of file FramebufferObject.hpp.

## Constructor & Destructor Documentation

vl::FBORenderTarget::~FBORenderTarget | ( | ) | `[inline]`

Destructor.

Definition at line 523 of file FramebufferObject.hpp.

## Member Function Documentation

virtual const char* vl::FBORenderTarget::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::RenderTarget.

Definition at line 520 of file FramebufferObject.hpp.

void FBORenderTarget::create | ( | ) |

Creates a framebuffer object by calling glGenFramebuffers().

See also:
  http://www.opengl.org/sdk/docs/man3/xhtml/glGenFramebuffers.xml

Definition at line 72 of file FramebufferObject.cpp.

References vl::OpenGLContext::makeCurrent(), mHandle, vl::RenderTarget::openglContext(), VL_CHECK, VL_CHECK_OGL, and vl::VL_glGenFramebuffers().

void FBORenderTarget::destroy | ( | ) |

Deletes a framebuffer object by calling glDeleteFramebuffers().

See also:
  http://www.opengl.org/sdk/docs/man3/xhtml/glDeleteFramebuffers.xml

Definition at line 85 of file FramebufferObject.cpp.

References handle(), vl::OpenGLContext::makeCurrent(), mHandle, vl::RenderTarget::openglContext(), removeAllAttachments(), vl::RenderTarget::setHeight(), vl::RenderTarget::setWidth(), VL_CHECK, VL_CHECK_OGL, vl::VL_glBindFramebuffer(), and vl::VL_glDeleteFramebuffers().

void vl::FBORenderTarget::setHandle | ( | GLuint | handle ) | `[inline]`

The handle of the framebuffer object as returned by glGenFramebuffers.

Definition at line 538 of file FramebufferObject.hpp.

virtual GLuint vl::FBORenderTarget::handle | ( | ) | const`[inline, virtual]`

The handle of the framebuffer object as returned by glGenFramebuffers.

Reimplemented from vl::RenderTarget.

Definition at line 541 of file FramebufferObject.hpp.

Referenced by bindFramebuffer(), checkFramebufferStatus(), destroy(), and removeAttachment().

void FBORenderTarget::bindFramebuffer | ( | EFrameBufferBind | target = `FBB_FRAMEBUFFER` ) | `[virtual]`

Makes the framebuffer the current rendering target calling glBindFramebuffer( GL_FRAMEBUFFER, FBORenderTarget::handle() ) and initializes all the previously defined attachment points.

See also:
  http://www.opengl.org/sdk/docs/man3/xhtml/glBindFramebuffer.xml

Reimplemented from vl::RenderTarget.

Definition at line 102 of file FramebufferObject.cpp.

References vl::RenderTarget::bindDrawBuffers(), vl::RenderTarget::bindReadBuffer(), vl::Log::error(), vl::FBB_DRAW_FRAMEBUFFER, vl::FBB_FRAMEBUFFER, vl::FBB_READ_FRAMEBUFFER, GLEW_Has_Framebuffer_Object, handle(), vl::RenderTarget::height(), vl::OpenGLContext::makeCurrent(), mFBOAttachments, vl::RenderTarget::openglContext(), printFramebufferError(), VL_CHECK, VL_CHECK_OGL, vl::VL_glBindFramebuffer(), vl::VL_glCheckFramebufferStatus(), VL_TRAP, and vl::RenderTarget::width().

GLenum FBORenderTarget::checkFramebufferStatus | ( | ) |

Checks the framebuffer status and returns the value of glCheckFramebufferStatus()

Returns 0 if no FBO support is found otherwise returns the value obtained by VL_glCheckFramebufferStatus()

Definition at line 153 of file FramebufferObject.cpp.

References vl::Log::error(), GLEW_Has_Framebuffer_Object, vl::globalSettings(), handle(), vl::RenderTarget::height(), vl::OpenGLContext::makeCurrent(), mFBOAttachments, vl::RenderTarget::openglContext(), printFramebufferError(), vl::VEL_VERBOSITY_NORMAL, VL_CHECK, VL_CHECK_OGL, vl::VL_glCheckFramebufferStatus(), and vl::RenderTarget::width().

void FBORenderTarget::printFramebufferError | ( | GLenum | status ) | const

Prints a human readable description of the error code as returned by glCheckFramebufferStatus()

Definition at line 198 of file FramebufferObject.cpp.

References vl::Log::bug(), and VL_TRAP.

Referenced by bindFramebuffer(), and checkFramebufferStatus().

void FBORenderTarget::addColorAttachment | ( | EAttachmentPoint | attach_point,
|  | FBOColorBufferAttachment * | attachment
| ) |  |

Binds a color attachment to a framebuffer object.

Definition at line 237 of file FramebufferObject.cpp.

References vl::AP_COLOR_ATTACHMENT0, vl::AP_COLOR_ATTACHMENT15, vl::FBORenderbufferAttachment::bindAttachment(), GLEW_Has_Framebuffer_Object, mFBOAttachments, vl::FBOAbstractAttachment::mFBORenderTargets, removeAttachment(), and VL_CHECK.

void FBORenderTarget::addTextureAttachment | ( | EAttachmentPoint | attach_point,
|  | FBOAbstractTextureAttachment * | attachment
| ) |  |

Binds a texture attachment to a framebuffer object.

Definition at line 249 of file FramebufferObject.cpp.

References vl::AP_COLOR_ATTACHMENT0, vl::AP_COLOR_ATTACHMENT15, vl::FBOAbstractAttachment::bindAttachment(), GLEW_Has_Framebuffer_Object, mFBOAttachments, vl::FBOAbstractAttachment::mFBORenderTargets, removeAttachment(), and VL_CHECK.

void FBORenderTarget::addDepthAttachment | ( | FBOAbstractAttachment * | attachment ) |

Binds a depth attachment to a framebuffer object.

The `attachment` parameter must point to either a FBODepthBufferAttachment or FBODepthStencilBufferAttachment.

Definition at line 261 of file FramebufferObject.cpp.

References vl::AP_DEPTH_ATTACHMENT, vl::FBOAbstractAttachment::bindAttachment(), GLEW_Has_Framebuffer_Object, mFBOAttachments, vl::FBOAbstractAttachment::mFBORenderTargets, removeAttachment(), and VL_CHECK.

void FBORenderTarget::addStencilAttachment | ( | FBOAbstractAttachment * | attachment ) |

Binds a stencil attachment to a framebuffer object.

The `attachment` parameter must point to either a FBOStencilBufferAttachment or FBODepthStencilBufferAttachment.

Definition at line 272 of file FramebufferObject.cpp.

References vl::AP_STENCIL_ATTACHMENT, vl::FBOAbstractAttachment::bindAttachment(), GLEW_Has_Framebuffer_Object, mFBOAttachments, vl::FBOAbstractAttachment::mFBORenderTargets, removeAttachment(), and VL_CHECK.

void FBORenderTarget::addDepthStencilAttachment | ( | FBOAbstractAttachment * | attachment ) |

Binds a depth-stencil attachment to a framebuffer object.

Definition at line 283 of file FramebufferObject.cpp.

References vl::AP_DEPTH_STENCIL_ATTACHMENT, vl::FBOAbstractAttachment::bindAttachment(), GLEW_Has_Framebuffer_Object, mFBOAttachments, vl::FBOAbstractAttachment::mFBORenderTargets, removeAttachment(), and VL_CHECK.

void FBORenderTarget::removeAttachment | ( | FBOAbstractAttachment * | attachment ) |

Unbinds the given attachments from a framebuffer object.

Definition at line 294 of file FramebufferObject.cpp.

References GLEW_Has_Framebuffer_Object, mFBOAttachments, and VL_CHECK.

Referenced by addColorAttachment(), addDepthAttachment(), addDepthStencilAttachment(), addStencilAttachment(), addTextureAttachment(), and removeAllAttachments().

void FBORenderTarget::removeAttachment | ( | EAttachmentPoint | attach_point ) |

Unbinds the attachment associated to the given attachment point from a framebuffer object.

Definition at line 311 of file FramebufferObject.cpp.

References GLEW_Has_Framebuffer_Object, handle(), vl::VisualizationLibrary::isGraphicsInitialized(), vl::OpenGLContext::makeCurrent(), mFBOAttachments, vl::FBOAbstractAttachment::mFBORenderTargets, vl::RenderTarget::openglContext(), VL_CHECK, VL_CHECK_OGL, vl::VL_glBindFramebuffer(), and vl::VL_glFramebufferRenderbuffer().

void FBORenderTarget::removeAllAttachments | ( | ) |

Unbinds all attachments bound to a framebuffer object.

Definition at line 341 of file FramebufferObject.cpp.

References GLEW_Has_Framebuffer_Object, mFBOAttachments, removeAttachment(), and VL_CHECK.

Referenced by destroy().

const std::map< EAttachmentPoint, ref<FBOAbstractAttachment> >& vl::FBORenderTarget::fboAttachments | ( | ) | const`[inline]`

A map associating which fbo-attachment belongs to which attachment point in a framebuffer object.

Definition at line 587 of file FramebufferObject.hpp.

## Friends And Related Function Documentation

friend class OpenGLContext`[friend]`

Reimplemented from vl::RenderTarget.

Definition at line 505 of file FramebufferObject.hpp.

## Member Data Documentation

std::map< EAttachmentPoint, ref<FBOAbstractAttachment> > vl::FBORenderTarget::mFBOAttachments

Definition at line 590 of file FramebufferObject.hpp.

Referenced by addColorAttachment(), addDepthAttachment(), addDepthStencilAttachment(), addStencilAttachment(), addTextureAttachment(), bindFramebuffer(), checkFramebufferStatus(), removeAllAttachments(), and removeAttachment().

GLuint vl::FBORenderTarget::mHandle

Definition at line 591 of file FramebufferObject.hpp.

Referenced by create(), and destroy().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/FramebufferObject.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/FramebufferObject.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:41.
Permission is granted to use this page to write and publish articles regarding Visualization Library.