A custom framebuffer object allows to draw to non-default framebuffer locations and offers the possibility to attach textures. More...

#include <Framebuffer.h>

Public Member Functions

 Framebuffer ()
 Constructor that takes care of the resolution automatically. More...
 
 Framebuffer (GLint width, GLint height)
 Constructor with fixed resolution. More...
 
virtual ~Framebuffer ()
 Virtual destructor. More...
 
virtual void bind (bool preserveCurrentFramebuffer)
 Bind the framebuffer object. More...
 
virtual void bindTexture (TexturePtr texture, bool preserveCurrentFramebuffer)
 Bind the framebuffer object and draw to the specified texture. More...
 
virtual void bindCubeMap (CubeMapPtr cubeMap, GLuint cubeFace, bool preserveCurrentFramebuffer)
 Bind the framebuffer object and draw to the specified cube map. More...
 
virtual void bindDepthMap (DepthMapPtr depthMap, bool preserveCurrentFramebuffer)
 Bind the framebuffer object and draw to the specified depth map. More...
 
virtual void unbind ()
 Unbind the framebuffer object. More...
 
virtual void unbind (GLint fbo)
 Unbind the framebuffer object and bind the specified framebuffer object. More...
 
virtual void resize (GLint width, GLint height, bool autoResize)
 Updates the size of the framebuffer. More...
 
GLuint getFramebufferID ()
 Get the framebuffer id. More...
 
GLuint getDebthbufferID ()
 Get the depthbuffer id. More...
 
GLint getWidth ()
 Get the width of the framebuffer. More...
 
GLint getHeight ()
 Get the height of the framebuffer. More...
 
virtual void deleteFramebuffer ()
 Delete the framebuffer. More...
 

Static Public Member Functions

static GLint getCurrentFramebuffer ()
 Get the framebuffer currently active. More...
 

Detailed Description

A custom framebuffer object allows to draw to non-default framebuffer locations and offers the possibility to attach textures.

Author
Benjamin Buergisser

Constructor & Destructor Documentation

Framebuffer::Framebuffer ( )

Constructor that takes care of the resolution automatically.

Framebuffer::Framebuffer ( GLint  width,
GLint  height 
)

Constructor with fixed resolution.

Parameters
[in]width
[in]height
virtual Framebuffer::~Framebuffer ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

void Framebuffer::bind ( bool  preserveCurrentFramebuffer)
virtual

Bind the framebuffer object.

Parameters
[in]preserveCurrentFramebufferIf true the framebuffer that was active before binding is bound again when unbinding
void Framebuffer::bindCubeMap ( CubeMapPtr  cubeMap,
GLuint  cubeFace,
bool  preserveCurrentFramebuffer 
)
virtual

Bind the framebuffer object and draw to the specified cube map.

Parameters
[in]cubeMapThe cube map to draw to
[in]cubeFaceDefines which face to bind: 0 = left, 1 = right, 2 = bottom, 3 = top, 4= front, 5 = back
[in]preserveCurrentFramebufferIf true the framebuffer that was active before binding is bound again when unbinding
void Framebuffer::bindDepthMap ( DepthMapPtr  depthMap,
bool  preserveCurrentFramebuffer 
)
virtual

Bind the framebuffer object and draw to the specified depth map.

Parameters
[in]depthMapThe depth map to draw to
[in]preserveCurrentFramebufferIf true the framebuffer that was active before binding is bound again when unbinding
void Framebuffer::bindTexture ( TexturePtr  texture,
bool  preserveCurrentFramebuffer 
)
virtual

Bind the framebuffer object and draw to the specified texture.

Parameters
[in]textureThe texture to draw to
[in]preserveCurrentFramebufferIf true the framebuffer that was active before binding is bound again when unbinding

Hint: Not all textures work, especially when changing resolution between frames. It's best to not use mip mapping. A suitable texture can be generated using Renderer::createTexture and not passing any data (GLenum format = GL_RGBA, ImageDataPtr imageData = nullptr) Do NOT use a cube map in this function!

void Framebuffer::deleteFramebuffer ( )
virtual

Delete the framebuffer.

GLint Framebuffer::getCurrentFramebuffer ( )
static

Get the framebuffer currently active.

GLuint Framebuffer::getDebthbufferID ( )
inline

Get the depthbuffer id.

GLuint Framebuffer::getFramebufferID ( )
inline

Get the framebuffer id.

GLint Framebuffer::getHeight ( )
inline

Get the height of the framebuffer.

GLint Framebuffer::getWidth ( )
inline

Get the width of the framebuffer.

void Framebuffer::resize ( GLint  width,
GLint  height,
bool  autoResize 
)
virtual

Updates the size of the framebuffer.

Parameters
[in]width
[in]height
[in]autoResizeSet true if the size should be reset to the viewport size automatically the next time the fbo is bound
void Framebuffer::unbind ( )
virtual

Unbind the framebuffer object.

void Framebuffer::unbind ( GLint  fbo)
virtual

Unbind the framebuffer object and bind the specified framebuffer object.

Parameters
[in]fboThe framebuffer object that should be bound after unbinding