Visualization Library 2.0.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Public Attributes | Friends | List of all members
vl::FramebufferObject 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::FramebufferObject:

Public Member Functions

 ~FramebufferObject ()
 Destructor. More...
 
void createFBO ()
 Creates a framebuffer object by calling glGenFramebuffers(). More...
 
void deleteFBO ()
 Deletes a framebuffer object by calling glDeleteFramebuffers(). More...
 
void setHandle (GLuint handle)
 The handle of the framebuffer object as returned by glGenFramebuffers. More...
 
virtual GLuint handle () const
 The handle of the framebuffer object as returned by glGenFramebuffers. More...
 
virtual void bindFramebuffer (EFramebufferBind target=FBB_FRAMEBUFFER)
 Makes the framebuffer the current rendering target calling glBindFramebuffer( GL_FRAMEBUFFER, FramebufferObject::handle() ) and initializes all the previously defined attachment points. More...
 
GLenum checkFramebufferStatus ()
 Checks the framebuffer status and returns the value of glCheckFramebufferStatus() More...
 
void printFramebufferError (GLenum status) const
 Prints a human readable description of the error code as returned by glCheckFramebufferStatus() More...
 
void addColorAttachment (EAttachmentPoint attach_point, FBOColorBufferAttachment *attachment)
 Binds a color attachment to a framebuffer object. More...
 
void addTextureAttachment (EAttachmentPoint attach_point, FBOAbstractTextureAttachment *attachment)
 Binds a texture attachment to a framebuffer object. More...
 
void addDepthAttachment (FBOAbstractAttachment *attachment)
 Binds a depth attachment to a framebuffer object. More...
 
void addStencilAttachment (FBOAbstractAttachment *attachment)
 Binds a stencil attachment to a framebuffer object. More...
 
void addDepthStencilAttachment (FBOAbstractAttachment *attachment)
 Binds a depth-stencil attachment to a framebuffer object. More...
 
void removeAttachment (FBOAbstractAttachment *attachment)
 Unbinds the given attachments from a framebuffer object. More...
 
void removeAttachment (EAttachmentPoint attach_point)
 Unbinds the attachment associated to the given attachment point from a framebuffer object. More...
 
void removeAllAttachments ()
 Unbinds all attachments bound to a framebuffer object. More...
 
const std::map< EAttachmentPoint, ref< FBOAbstractAttachment > > & fboAttachments () const
 A map associating which fbo-attachment belongs to which attachment point in a framebuffer object. More...
 
- Public Member Functions inherited from vl::Framebuffer
 Framebuffer (OpenGLContext *ctx, int w, int h, EReadDrawBuffer draw_buffer, EReadDrawBuffer read_buffer)
 Constructor, see also OpenGLContext::framebuffer(). More...
 
OpenGLContextopenglContext ()
 The OpenGLContext bound to a render target. More...
 
const OpenGLContextopenglContext () const
 The OpenGLContext bound to a render target. More...
 
int width () const
 The width of a render target. More...
 
int height () const
 The height of a render target. More...
 
void setWidth (int width)
 The width of a render target. More...
 
void setHeight (int height)
 The height of a render target. More...
 
void activate (EFramebufferBind target=FBB_FRAMEBUFFER)
 Activates the Framebuffer by calling bindFramebuffer() and bindDrawBuffers() More...
 
void bindReadBuffer ()
 Binds to the currently active framebuffer object (including the 0 one) the read buffer specified by setReadBuffer(). More...
 
void bindDrawBuffers () const
 Binds to the currently active framebuffer object (including the 0 one) the draw buffers specified by setDrawBuffers(). More...
 
bool checkDrawBuffers () const
 Returns true if the draw buffers bound to this render target are legal for this render target type. More...
 
void setDrawBuffer (EReadDrawBuffer draw_buffer)
 Specifies the color buffer to be drawn into. More...
 
void setDrawBuffers (EReadDrawBuffer draw_buffer1, EReadDrawBuffer draw_buffer2)
 Specifies a list of color buffers to be drawn into. More...
 
void setDrawBuffers (EReadDrawBuffer draw_buffer1, EReadDrawBuffer draw_buffer2, EReadDrawBuffer draw_buffer3)
 Specifies a list of color buffers to be drawn into. More...
 
void setDrawBuffers (EReadDrawBuffer draw_buffer1, EReadDrawBuffer draw_buffer2, EReadDrawBuffer draw_buffer3, EReadDrawBuffer draw_buffer4)
 Specifies a list of color buffers to be drawn into. More...
 
void setDrawBuffers (const std::vector< EReadDrawBuffer > &draw_buffers)
 Specifies a list of color buffers to be drawn into. More...
 
const std::vector< EReadDrawBuffer > & drawBuffers ()
 The color buffers to be drawn into. More...
 
EReadDrawBuffer readBuffer () const
 The read-buffer bound when the render target is activated. More...
 
void setReadBuffer (EReadDrawBuffer read_buffer)
 The read-buffer bound when the render target is activated. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Public Attributes

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

Friends

class OpenGLContext
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

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

An FramebufferObject belongs to one and only one OpenGLContext and can be created using the OpenGLContext::createFramebufferObject() method. To render to a FramebufferObject use the Rendering::setFramebuffer() function.

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

Definition at line 538 of file FramebufferObject.hpp.

Constructor & Destructor Documentation

◆ ~FramebufferObject()

vl::FramebufferObject::~FramebufferObject ( )
inline

Destructor.

Definition at line 565 of file FramebufferObject.hpp.

Member Function Documentation

◆ addColorAttachment()

void FramebufferObject::addColorAttachment ( EAttachmentPoint  attach_point,
FBOColorBufferAttachment attachment 
)

◆ addDepthAttachment()

void FramebufferObject::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 262 of file FramebufferObject.cpp.

References vl::AP_DEPTH_ATTACHMENT, vl::FBOAbstractAttachment::bindAttachment(), vl::Has_FBO, vl::FBOAbstractAttachment::mFramebufferObjects, and VL_CHECK.

◆ addDepthStencilAttachment()

void FramebufferObject::addDepthStencilAttachment ( FBOAbstractAttachment attachment)

Binds a depth-stencil attachment to a framebuffer object.

Definition at line 284 of file FramebufferObject.cpp.

References vl::AP_DEPTH_STENCIL_ATTACHMENT, vl::FBOAbstractAttachment::bindAttachment(), vl::Has_FBO, vl::FBOAbstractAttachment::mFramebufferObjects, and VL_CHECK.

◆ addStencilAttachment()

void FramebufferObject::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 273 of file FramebufferObject.cpp.

References vl::AP_STENCIL_ATTACHMENT, vl::FBOAbstractAttachment::bindAttachment(), vl::Has_FBO, vl::FBOAbstractAttachment::mFramebufferObjects, and VL_CHECK.

◆ addTextureAttachment()

void FramebufferObject::addTextureAttachment ( EAttachmentPoint  attach_point,
FBOAbstractTextureAttachment attachment 
)

◆ bindFramebuffer()

void FramebufferObject::bindFramebuffer ( EFramebufferBind  target = FBB_FRAMEBUFFER)
virtual

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

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

Reimplemented from vl::Framebuffer.

Definition at line 101 of file FramebufferObject.cpp.

References vl::Log::error(), vl::FBB_DRAW_FRAMEBUFFER, vl::FBB_FRAMEBUFFER, vl::FBB_READ_FRAMEBUFFER, vl::Has_FBO, VL_CHECK, VL_CHECK_OGL, and VL_TRAP.

◆ checkFramebufferStatus()

GLenum FramebufferObject::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 154 of file FramebufferObject.cpp.

References vl::Log::error(), vl::globalSettings(), vl::Has_FBO, vl::VEL_VERBOSITY_NORMAL, VL_CHECK, and VL_CHECK_OGL.

◆ createFBO()

void FramebufferObject::createFBO ( )

Creates a framebuffer object by calling glGenFramebuffers().

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

Definition at line 71 of file FramebufferObject.cpp.

References VL_CHECK, and VL_CHECK_OGL.

◆ deleteFBO()

void FramebufferObject::deleteFBO ( )

Deletes a framebuffer object by calling glDeleteFramebuffers().

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

Definition at line 84 of file FramebufferObject.cpp.

References VL_CHECK, and VL_CHECK_OGL.

◆ fboAttachments()

const std::map< EAttachmentPoint, ref<FBOAbstractAttachment> >& vl::FramebufferObject::fboAttachments ( ) const
inline

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

Definition at line 629 of file FramebufferObject.hpp.

◆ handle()

virtual GLuint vl::FramebufferObject::handle ( ) const
inlinevirtual

The handle of the framebuffer object as returned by glGenFramebuffers.

Reimplemented from vl::Framebuffer.

Definition at line 583 of file FramebufferObject.hpp.

References vl::FBB_FRAMEBUFFER.

◆ printFramebufferError()

void FramebufferObject::printFramebufferError ( GLenum  status) const

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

Definition at line 199 of file FramebufferObject.cpp.

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

◆ removeAllAttachments()

void FramebufferObject::removeAllAttachments ( )

Unbinds all attachments bound to a framebuffer object.

Definition at line 340 of file FramebufferObject.cpp.

References vl::Has_FBO, and VL_CHECK.

◆ removeAttachment() [1/2]

void FramebufferObject::removeAttachment ( FBOAbstractAttachment attachment)

Unbinds the given attachments from a framebuffer object.

Definition at line 295 of file FramebufferObject.cpp.

References vl::Has_FBO, and VL_CHECK.

◆ removeAttachment() [2/2]

void FramebufferObject::removeAttachment ( EAttachmentPoint  attach_point)

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

Definition at line 312 of file FramebufferObject.cpp.

References vl::Has_FBO, vl::FBOAbstractAttachment::mFramebufferObjects, VL_CHECK, and VL_CHECK_OGL.

◆ setHandle()

void vl::FramebufferObject::setHandle ( GLuint  handle)
inline

The handle of the framebuffer object as returned by glGenFramebuffers.

Definition at line 580 of file FramebufferObject.hpp.

Friends And Related Function Documentation

◆ OpenGLContext

friend class OpenGLContext
friend

Definition at line 542 of file FramebufferObject.hpp.

Member Data Documentation

◆ mFBOAttachments

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

Definition at line 632 of file FramebufferObject.hpp.

◆ mHandle

GLuint vl::FramebufferObject::mHandle

Definition at line 633 of file FramebufferObject.hpp.


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