Visualization Library 2.1.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...
 
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 FramebufferObject 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...
 
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...
 
bool externallyManaged () const
 Wen externallyManaged() == true then this function does nothing. More...
 
void setExternallyManaged (bool em)
 Wen externallyManaged() == true then this function does nothing. 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::vector< EReadDrawBuffermDrawBuffers
 
EReadDrawBuffer mReadBuffer
 
OpenGLContextmOpenGLContext
 
int mWidth
 
int mHeight
 
std::map< EAttachmentPoint, ref< FBOAbstractAttachment > > mFBOAttachments
 
GLuint mHandle
 
bool mExternallyManaged
 

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 544 of file FramebufferObject.hpp.

Constructor & Destructor Documentation

◆ ~FramebufferObject()

vl::FramebufferObject::~FramebufferObject ( )
inline

Destructor.

Definition at line 595 of file FramebufferObject.hpp.

Member Function Documentation

◆ activate()

void vl::FramebufferObject::activate ( EFramebufferBind  target = FBB_FRAMEBUFFER)
inline

◆ 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 400 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 422 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 411 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 
)

◆ bindDrawBuffers()

void FramebufferObject::bindDrawBuffers ( ) const

Binds to the currently active framebuffer object (including the 0 one) the draw buffers specified by setDrawBuffers().

Definition at line 158 of file FramebufferObject.cpp.

References vl::Log::error(), vl::Has_GL_Version_2_0, VL_CHECK, and VL_CHECK_OGL.

◆ 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.

Wen externallyManaged() == true then this function does nothing. This is used when external logic is handling the framebuffer for example for compositing and off-screen rendering (eg Qt 6 QOpenGLWidget).

See also

Definition at line 225 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.

◆ bindReadBuffer()

void FramebufferObject::bindReadBuffer ( )

Binds to the currently active framebuffer object (including the 0 one) the read buffer specified by setReadBuffer().

Definition at line 186 of file FramebufferObject.cpp.

References VL_CHECK_OGL.

◆ checkDrawBuffers()

bool FramebufferObject::checkDrawBuffers ( ) const

Returns true if the draw buffers bound to this render target are legal for this render target type.

Definition at line 71 of file FramebufferObject.cpp.

References vl::Log::error().

◆ 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 292 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 195 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 208 of file FramebufferObject.cpp.

References VL_CHECK, and VL_CHECK_OGL.

◆ drawBuffers()

const std::vector< EReadDrawBuffer >& vl::FramebufferObject::drawBuffers ( )
inline

The color buffers to be drawn into.

Definition at line 665 of file FramebufferObject.hpp.

◆ externallyManaged()

bool vl::FramebufferObject::externallyManaged ( ) const
inline

Wen externallyManaged() == true then this function does nothing.

This is used when external logic is handling the framebuffer for example for compositing and off-screen rendering (eg Qt 6 QOpenGLWidget).

Definition at line 747 of file FramebufferObject.hpp.

◆ 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 743 of file FramebufferObject.hpp.

◆ handle()

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

The handle of the framebuffer object as returned by glGenFramebuffers.

Definition at line 691 of file FramebufferObject.hpp.

References vl::FBB_FRAMEBUFFER.

◆ height()

int vl::FramebufferObject::height ( ) const
inline

◆ openglContext() [1/2]

OpenGLContext* vl::FramebufferObject::openglContext ( )
inline

◆ openglContext() [2/2]

const OpenGLContext* vl::FramebufferObject::openglContext ( ) const
inline

The OpenGLContext bound to a render target.

Definition at line 601 of file FramebufferObject.hpp.

◆ printFramebufferError()

void FramebufferObject::printFramebufferError ( GLenum  status) const

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

Definition at line 337 of file FramebufferObject.cpp.

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

◆ readBuffer()

EReadDrawBuffer vl::FramebufferObject::readBuffer ( ) const
inline

The read-buffer bound when the render target is activated.

Definition at line 668 of file FramebufferObject.hpp.

◆ removeAllAttachments()

void FramebufferObject::removeAllAttachments ( )

Unbinds all attachments bound to a framebuffer object.

Definition at line 478 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 433 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 450 of file FramebufferObject.cpp.

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

◆ setDrawBuffer()

void vl::FramebufferObject::setDrawBuffer ( EReadDrawBuffer  draw_buffer)
inline

Specifies the color buffer to be drawn into.

Definition at line 628 of file FramebufferObject.hpp.

◆ setDrawBuffers() [1/4]

void vl::FramebufferObject::setDrawBuffers ( EReadDrawBuffer  draw_buffer1,
EReadDrawBuffer  draw_buffer2 
)
inline

Specifies a list of color buffers to be drawn into.

Definition at line 635 of file FramebufferObject.hpp.

◆ setDrawBuffers() [2/4]

void vl::FramebufferObject::setDrawBuffers ( EReadDrawBuffer  draw_buffer1,
EReadDrawBuffer  draw_buffer2,
EReadDrawBuffer  draw_buffer3 
)
inline

Specifies a list of color buffers to be drawn into.

Definition at line 643 of file FramebufferObject.hpp.

◆ setDrawBuffers() [3/4]

void vl::FramebufferObject::setDrawBuffers ( EReadDrawBuffer  draw_buffer1,
EReadDrawBuffer  draw_buffer2,
EReadDrawBuffer  draw_buffer3,
EReadDrawBuffer  draw_buffer4 
)
inline

Specifies a list of color buffers to be drawn into.

Definition at line 652 of file FramebufferObject.hpp.

◆ setDrawBuffers() [4/4]

void vl::FramebufferObject::setDrawBuffers ( const std::vector< EReadDrawBuffer > &  draw_buffers)
inline

Specifies a list of color buffers to be drawn into.

Definition at line 662 of file FramebufferObject.hpp.

◆ setExternallyManaged()

void vl::FramebufferObject::setExternallyManaged ( bool  em)
inline

Wen externallyManaged() == true then this function does nothing.

This is used when external logic is handling the framebuffer for example for compositing and off-screen rendering (eg Qt 6 QOpenGLWidget).

Definition at line 750 of file FramebufferObject.hpp.

Referenced by vlQt6::Qt6Widget::initializeGL().

◆ setHandle()

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

The handle of the framebuffer object as returned by glGenFramebuffers.

Definition at line 688 of file FramebufferObject.hpp.

◆ setHeight()

void vl::FramebufferObject::setHeight ( int  height)
inline

The height of a render target.

Definition at line 613 of file FramebufferObject.hpp.

Referenced by vlGLUT::GLUTWindow::glut_reshape_func(), vlWin32::Win32Window::WindowProc(), and vlEGL::EGLWindow::WindowProc().

◆ setReadBuffer()

void vl::FramebufferObject::setReadBuffer ( EReadDrawBuffer  read_buffer)
inline

The read-buffer bound when the render target is activated.

Definition at line 671 of file FramebufferObject.hpp.

◆ setWidth()

void vl::FramebufferObject::setWidth ( int  width)
inline

The width of a render target.

Definition at line 610 of file FramebufferObject.hpp.

Referenced by vlGLUT::GLUTWindow::glut_reshape_func(), vlWin32::Win32Window::WindowProc(), and vlEGL::EGLWindow::WindowProc().

◆ width()

int vl::FramebufferObject::width ( ) const
inline

Friends And Related Function Documentation

◆ OpenGLContext

friend class OpenGLContext
friend

Definition at line 548 of file FramebufferObject.hpp.

Member Data Documentation

◆ mDrawBuffers

std::vector< EReadDrawBuffer > vl::FramebufferObject::mDrawBuffers

Definition at line 753 of file FramebufferObject.hpp.

◆ mExternallyManaged

bool vl::FramebufferObject::mExternallyManaged

Definition at line 761 of file FramebufferObject.hpp.

◆ mFBOAttachments

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

Definition at line 759 of file FramebufferObject.hpp.

◆ mHandle

GLuint vl::FramebufferObject::mHandle

Definition at line 760 of file FramebufferObject.hpp.

◆ mHeight

int vl::FramebufferObject::mHeight

Definition at line 757 of file FramebufferObject.hpp.

◆ mOpenGLContext

OpenGLContext* vl::FramebufferObject::mOpenGLContext

Definition at line 755 of file FramebufferObject.hpp.

◆ mReadBuffer

EReadDrawBuffer vl::FramebufferObject::mReadBuffer

Definition at line 754 of file FramebufferObject.hpp.

◆ mWidth

int vl::FramebufferObject::mWidth

Definition at line 756 of file FramebufferObject.hpp.


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