gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
FramebufferObject Class Reference

#include <framebufferObject.h>

Collaboration diagram for FramebufferObject:
Collaboration graph

Public Member Functions

 FramebufferObject ()
 Ctor/Dtor. More...
 
virtual ~FramebufferObject ()
 
void Bind ()
 Bind this FBO as current render target. More...
 
virtual void AttachTexture (GLenum texTarget, GLuint texId, GLenum attachment=GL_COLOR_ATTACHMENT0, int mipLevel=0, int zSlice=0)
 Bind a texture to the "attachment" point of this FBO. More...
 
virtual void AttachTextures (int numTextures, GLenum texTarget[], GLuint texId[], GLenum attachment[]=NULL, int mipLevel[]=NULL, int zSlice[]=NULL)
 
virtual void AttachRenderBuffer (GLuint buffId, GLenum attachment=GL_COLOR_ATTACHMENT0)
 Bind a render buffer to the "attachment" point of this FBO. More...
 
virtual void AttachRenderBuffers (int numBuffers, GLuint buffId[], GLenum attachment[]=NULL)
 
void Unattach (GLenum attachment)
 Free any resource bound to the "attachment" point of this FBO. More...
 
void UnattachAll ()
 Free any resources bound to any attachment points of this FBO. More...
 
bool IsValid (std::ostream &ostr=std::cerr)
 
GLenum GetAttachedType (GLenum attachment)
 Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE? More...
 
GLuint GetAttachedId (GLenum attachment)
 
GLint GetAttachedMipLevel (GLenum attachment)
 Which mipmap level is currently attached to "attachement?". More...
 
GLint GetAttachedCubeFace (GLenum attachment)
 Which cube face is currently attached to "attachment?". More...
 
GLuint getID () const
 END : Static methods global to all FBOs. More...
 

Static Public Member Functions

static int GetMaxColorAttachments ()
 Which z-slice is currently attached to "attachment?". More...
 
static void Disable ()
 

Protected Member Functions

void _GuardedBind ()
 
void _GuardedUnbind ()
 
void _FramebufferTextureND (GLenum attachment, GLenum texTarget, GLuint texId, int mipLevel, int zSlice)
 

Static Protected Member Functions

static GLuint _GenerateFboId ()
 

Detailed Description

FramebufferObject Class. This class encapsulates the FramebufferObject (FBO) OpenGL spec. See the official spec at: http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt

for details.

A framebuffer 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. For example:

FramebufferObject fbo; fbo.Bind(); fbo.AttachTexture(GL_TEXTURE_2D, texId0, GL_COLOR_ATTACHMENT0_EXT); fbo.AttachTexture(GL_TEXTURE_2D, texId1, GL_COLOR_ATTACHMENT1_EXT); fbo.IsValid();

To provide a complete encapsulation, the following usage pattern works correctly but is less efficient:

FramebufferObject fbo; NOTE : No Bind() call fbo.AttachTexture(GL_TEXTURE_2D, texId0, GL_COLOR_ATTACHMENT0_EXT); fbo.AttachTexture(GL_TEXTURE_2D, texId1, GL_COLOR_ATTACHMENT1_EXT); fbo.IsValid();

The first usage pattern binds the FBO only once, whereas the second usage binds/unbinds the FBO for each method call.

2) Use FramebufferObject::Disable() sparingly. We have intentionally left out an "Unbind()" method because it is largely unnecessary and encourages rendundant Bind/Unbind coding. 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, the following usage pattern is recommended:

FramebufferObject fbo1, fbo2; fbo1.Bind(); ... Render ... NOTE : No Unbind/Disable here...

  fbo2.Bind();
    ... Render ...

Disable FBO rendering and return to visible window OpenGL framebuffer. FramebufferObject::Disable();

Definition at line 107 of file framebufferObject.h.

Constructor & Destructor Documentation

◆ FramebufferObject()

FramebufferObject::FramebufferObject ( )

Ctor/Dtor.

◆ ~FramebufferObject()

virtual FramebufferObject::~FramebufferObject ( )
virtual

Member Function Documentation

◆ _FramebufferTextureND()

void FramebufferObject::_FramebufferTextureND ( GLenum  attachment,
GLenum  texTarget,
GLuint  texId,
int  mipLevel,
int  zSlice 
)
protected

◆ _GenerateFboId()

static GLuint FramebufferObject::_GenerateFboId ( )
staticprotected

◆ _GuardedBind()

void FramebufferObject::_GuardedBind ( )
protected

◆ _GuardedUnbind()

void FramebufferObject::_GuardedUnbind ( )
protected

◆ AttachRenderBuffer()

virtual void FramebufferObject::AttachRenderBuffer ( GLuint  buffId,
GLenum  attachment = GL_COLOR_ATTACHMENT0 
)
virtual

Bind a render buffer to the "attachment" point of this FBO.

◆ AttachRenderBuffers()

virtual void FramebufferObject::AttachRenderBuffers ( int  numBuffers,
GLuint  buffId[],
GLenum  attachment[] = NULL 
)
virtual

Bind an array of render buffers to corresponding "attachment" points of this FBO.

  • By default, the first 'numBuffers' attachments are used, starting with GL_COLOR_ATTACHMENT0_EXT

◆ AttachTexture()

virtual void FramebufferObject::AttachTexture ( GLenum  texTarget,
GLuint  texId,
GLenum  attachment = GL_COLOR_ATTACHMENT0,
int  mipLevel = 0,
int  zSlice = 0 
)
virtual

Bind a texture to the "attachment" point of this FBO.

◆ AttachTextures()

virtual void FramebufferObject::AttachTextures ( int  numTextures,
GLenum  texTarget[],
GLuint  texId[],
GLenum  attachment[] = NULL,
int  mipLevel[] = NULL,
int  zSlice[] = NULL 
)
virtual

Bind an array of textures to multiple "attachment" points of this FBO

  • By default, the first 'numTextures' attachments are used, starting with GL_COLOR_ATTACHMENT0_EXT

◆ Bind()

void FramebufferObject::Bind ( )

Bind this FBO as current render target.

◆ Disable()

static void FramebufferObject::Disable ( )
static

Disable all FBO rendering and return to traditional, windowing-system controlled framebuffer NOTE: This is NOT an "unbind" for this specific FBO, but rather disables all FBO rendering. This call is intentionally "static" and named "Disable" instead of "Unbind" for this reason. The motivation for this strange semantic is performance. Providing "Unbind" would likely lead to a large number of unnecessary FBO enablings/disabling.

◆ GetAttachedCubeFace()

GLint FramebufferObject::GetAttachedCubeFace ( GLenum  attachment)

Which cube face is currently attached to "attachment?".

◆ GetAttachedId()

GLuint FramebufferObject::GetAttachedId ( GLenum  attachment)

What is the Id of Renderbuffer/texture currently attached to "attachement?"

◆ GetAttachedMipLevel()

GLint FramebufferObject::GetAttachedMipLevel ( GLenum  attachment)

Which mipmap level is currently attached to "attachement?".

◆ GetAttachedType()

GLenum FramebufferObject::GetAttachedType ( GLenum  attachment)

Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE?

BEGIN : Accessors

◆ getID()

GLuint FramebufferObject::getID ( ) const
inline

END : Static methods global to all FBOs.

Definition at line 201 of file framebufferObject.h.

◆ GetMaxColorAttachments()

static int FramebufferObject::GetMaxColorAttachments ( )
static

Which z-slice is currently attached to "attachment?".

END : Accessors BEGIN : Static methods global to all FBOs Return number of color attachments permitted

◆ IsValid()

bool FramebufferObject::IsValid ( std::ostream &  ostr = std::cerr)

Is this FBO currently a valid render target?

  • Sends output to std::cerr by default but can be a user-defined C++ stream

NOTE : This function works correctly in debug build mode but always returns "true" if NDEBUG is is defined (optimized builds)

◆ Unattach()

void FramebufferObject::Unattach ( GLenum  attachment)

Free any resource bound to the "attachment" point of this FBO.

◆ UnattachAll()

void FramebufferObject::UnattachAll ( )

Free any resources bound to any attachment points of this FBO.


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