Loading...
Searching...
No Matches
globjects::Framebuffer Class Reference

Enables creation of arbitrary render targets that are not directly drawn on the screen. More...

`#include <globjects/include/globjects/Framebuffer.h>`

Inheritance diagram for globjects::Framebuffer:

## Public Types

enum class | BindlessImplementation { DirectStateAccessARB , DirectStateAccessEXT , Legacy }
Public Types inherited from globjects::Object
enum class | NameImplementation { DebugKHR , Legacy }

## Public Member Functions

| Framebuffer ()
virtual void | accept (ObjectVisitor &visitor) override
void | bind () const
void | bind (gl::GLenum target) const
void | setParameter (gl::GLenum pname, gl::GLint param)
gl::GLint | getAttachmentParameter (gl::GLenum attachment, gl::GLenum pname) const
void | attachTexture (gl::GLenum attachment, Texture *texture, gl::GLint level=0)
void | attachTextureLayer (gl::GLenum attachment, Texture *texture, gl::GLint level=0, gl::GLint layer=0)
void | attachRenderBuffer (gl::GLenum attachment, Renderbuffer *renderBuffer)
bool | detach (gl::GLenum attachment)
void | setReadBuffer (gl::GLenum mode) const
void | setDrawBuffer (gl::GLenum mode) const
void | setDrawBuffers (gl::GLsizei n, const gl::GLenum *modes) const
void | setDrawBuffers (const std::vector< gl::GLenum > &modes) const
void | clear (gl::ClearBufferMask mask)
void | clearBufferiv (gl::GLenum buffer, gl::GLint drawBuffer, const gl::GLint *value)
void | clearBufferuiv (gl::GLenum buffer, gl::GLint drawBuffer, const gl::GLuint *value)
void | clearBufferfv (gl::GLenum buffer, gl::GLint drawBuffer, const gl::GLfloat *value)
void | clearBufferfi (gl::GLenum buffer, gl::GLint drawBuffer, gl::GLfloat depth, gl::GLint stencil)
void | clearBuffer (gl::GLenum buffer, gl::GLint drawBuffer, const glm::ivec4 &value)
void | clearBuffer (gl::GLenum buffer, gl::GLint drawBuffer, const glm::uvec4 &value)
void | clearBuffer (gl::GLenum buffer, gl::GLint drawBuffer, const glm::vec4 &value)
void | readPixels (gl::GLint x, gl::GLint y, gl::GLsizei width, gl::GLsizei height, gl::GLenum format, gl::GLenum type, gl::GLvoid *data=nullptr) const
void | readPixels (const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type, gl::GLvoid *data=nullptr) const
void | readPixels (gl::GLenum readBuffer, const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type, gl::GLvoid *data=nullptr) const
std::vector< unsigned char > | readPixelsToByteArray (const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type) const
std::vector< unsigned char > | readPixelsToByteArray (gl::GLenum readBuffer, const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type) const
void | readPixelsToBuffer (const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type, Buffer *pbo) const
gl::GLenum | checkStatus () const
std::string | statusString () const
void | printStatus (bool onlyErrors=false) const
FramebufferAttachment * | getAttachment (gl::GLenum attachment)
std::vector< FramebufferAttachment * > | attachments ()
void | blit (gl::GLenum readBuffer, const std::array< gl::GLint, 4 > &srcRect, Framebuffer *destFbo, gl::GLenum drawBuffer, const std::array< gl::GLint, 4 > &destRect, gl::ClearBufferMask mask, gl::GLenum filter) const
void | blit (gl::GLenum readBuffer, const std::array< gl::GLint, 4 > &srcRect, Framebuffer *destFbo, const std::vector< gl::GLenum > &drawBuffers, const std::array< gl::GLint, 4 > &destRect, gl::ClearBufferMask mask, gl::GLenum filter) const
virtual gl::GLenum | objectType () const override
Public Member Functions inherited from globjects::Object
gl::GLuint | id () const
std::string | name () const
void | setName (const std::string &name)
bool | hasName () const
bool | isDefault () const
void | detach ()
Public Member Functions inherited from globjects::Referenced
| Referenced ()
void | ref () const
void | unref () const
int | refCounter () const
Public Member Functions inherited from globjects::HeapOnly
| HeapOnly ()
void | destroy () const

## Static Public Member Functions

static void | hintBindlessImplementation (BindlessImplementation impl)
static Framebuffer * | fromId (gl::GLuint id)
static Framebuffer * | defaultFBO ()
static void | unbind ()
static void | unbind (gl::GLenum target)
static void | colorMask (gl::GLboolean red, gl::GLboolean green, gl::GLboolean blue, gl::GLboolean alpha)
static void | colorMask (const glm::bvec4 &mask)
static void | colorMaski (gl::GLuint buffer, gl::GLboolean red, gl::GLboolean green, gl::GLboolean blue, gl::GLboolean alpha)
static void | colorMaski (gl::GLuint buffer, const glm::bvec4 &mask)
static void | clearColor (gl::GLfloat red, gl::GLfloat green, gl::GLfloat blue, gl::GLfloat alpha)
static void | clearColor (const glm::vec4 &color)
static void | clearDepth (gl::GLclampd depth)
Static Public Member Functions inherited from globjects::Object
static void | hintNameImplementation (NameImplementation impl)

## Protected Member Functions

| Framebuffer (IDResource *resource)
virtual | ~Framebuffer ()
void | addAttachment (FramebufferAttachment *attachment)
Protected Member Functions inherited from globjects::Object
| Object (IDResource *resource)
virtual | ~Object ()
Protected Member Functions inherited from globjects::Referenced
virtual | ~Referenced ()
Protected Member Functions inherited from globjects::HeapOnly
virtual | ~HeapOnly ()

## Static Protected Member Functions

static void | blit (gl::GLint srcX0, gl::GLint srcY0, gl::GLint srcX1, gl::GLint srcY1, gl::GLint destX0, gl::GLint destY0, gl::GLint destX1, gl::GLint destY1, gl::ClearBufferMask mask, gl::GLenum filter)
static void | blit (const std::array< gl::GLint, 4 > &srcRect, const std::array< gl::GLint, 4 > &destRect, gl::ClearBufferMask mask, gl::GLenum filter)

## Protected Attributes

std::map< gl::GLenum, ref_ptr< FramebufferAttachment > > | m_attachments
Protected Attributes inherited from globjects::Object
IDResource * | m_resource
void * | m_objectLabelState

## Detailed Description

Enables creation of arbitrary render targets that are not directly drawn on the screen.

Different attachments can be added with attachTexture(), attachTexture1D(), attachTexture2D, attachTextureLayer() and attachRenderBuffer() and queried using attachment() and attachments().

To access the default FBO (e.g. if you want to blit an FBO to it), call defaultFBO(). To blit between two FBOs, prepare them with setReadBuffer() and setDrawBuffer() and blit with blit().

Draw restrictions can be done with setDrawBuffers(). To read pixels from an FBO direct into RAM, use readPixels() and to read into an OpenGL buffer use readPixelsToBuffer(). To check if an FBO is setup correctly, the status can be checked using checkStatus(), statusString() and printStatus().

See also
  http://www.opengl.org/wiki/Framebuffer_Object
  FrameBufferAttachment
  TextureAttachment
  RenderBufferAttachment

## Member Enumeration Documentation

## BindlessImplementation

enum class globjects::Framebuffer::BindlessImplementation

strong

Enumerator
DirectStateAccessARB |
DirectStateAccessEXT |
Legacy |

## Constructor & Destructor Documentation

## Framebuffer() [1/2]

globjects::Framebuffer::Framebuffer | ( |  | ) |

## Framebuffer() [2/2]

globjects::Framebuffer::Framebuffer | ( | IDResource * | resource | ) |

protected

## ~Framebuffer()

virtual globjects::Framebuffer::~Framebuffer | ( |  | ) |

protected virtual

## Member Function Documentation

## hintBindlessImplementation()

static void globjects::Framebuffer::hintBindlessImplementation | ( | BindlessImplementation | impl | ) |

static

## fromId()

static Framebuffer * globjects::Framebuffer::fromId | ( | gl::GLuint | id | ) |

static

## defaultFBO()

static Framebuffer * globjects::Framebuffer::defaultFBO | ( |  | ) |

static

## accept()

virtual void globjects::Framebuffer::accept | ( | ObjectVisitor & | visitor | ) |

override virtual

Implements globjects::Object.

## bind() [1/2]

void globjects::Framebuffer::bind | ( |  | ) | const

uses GL_FRAMEBUFFER as target

## bind() [2/2]

void globjects::Framebuffer::bind | ( | gl::GLenum | target | ) | const

## unbind() [1/2]

static void globjects::Framebuffer::unbind | ( |  | ) |

static

uses GL_FRAMEBUFFER as target

## unbind() [2/2]

static void globjects::Framebuffer::unbind | ( | gl::GLenum | target | ) |

static

## setParameter()

void globjects::Framebuffer::setParameter | ( | gl::GLenum | pname,
|  | gl::GLint | param
| ) |  |

## getAttachmentParameter()

gl::GLint globjects::Framebuffer::getAttachmentParameter | ( | gl::GLenum | attachment,
|  | gl::GLenum | pname
| ) |  | const

## attachTexture()

void globjects::Framebuffer::attachTexture | ( | gl::GLenum | attachment,
|  | Texture * | texture,
|  | gl::GLint | level = `0`
| ) |  |

## attachTextureLayer()

void globjects::Framebuffer::attachTextureLayer | ( | gl::GLenum | attachment,
|  | Texture * | texture,
|  | gl::GLint | level = `0`,
|  | gl::GLint | layer = `0`
| ) |  |

## attachRenderBuffer()

void globjects::Framebuffer::attachRenderBuffer | ( | gl::GLenum | attachment,
|  | Renderbuffer * | renderBuffer
| ) |  |

## detach()

bool globjects::Framebuffer::detach | ( | gl::GLenum | attachment | ) |

## setReadBuffer()

void globjects::Framebuffer::setReadBuffer | ( | gl::GLenum | mode | ) | const

## setDrawBuffer()

void globjects::Framebuffer::setDrawBuffer | ( | gl::GLenum | mode | ) | const

## setDrawBuffers() [1/2]

void globjects::Framebuffer::setDrawBuffers | ( | gl::GLsizei | n,
|  | const gl::GLenum * | modes
| ) |  | const

## setDrawBuffers() [2/2]

void globjects::Framebuffer::setDrawBuffers | ( | const std::vector< gl::GLenum > & | modes | ) | const

## clear()

void globjects::Framebuffer::clear | ( | gl::ClearBufferMask | mask | ) |

## clearBufferiv()

void globjects::Framebuffer::clearBufferiv | ( | gl::GLenum | buffer,
|  | gl::GLint | drawBuffer,
|  | const gl::GLint * | value
| ) |  |

## clearBufferuiv()

void globjects::Framebuffer::clearBufferuiv | ( | gl::GLenum | buffer,
|  | gl::GLint | drawBuffer,
|  | const gl::GLuint * | value
| ) |  |

## clearBufferfv()

void globjects::Framebuffer::clearBufferfv | ( | gl::GLenum | buffer,
|  | gl::GLint | drawBuffer,
|  | const gl::GLfloat * | value
| ) |  |

## clearBufferfi()

void globjects::Framebuffer::clearBufferfi | ( | gl::GLenum | buffer,
|  | gl::GLint | drawBuffer,
|  | gl::GLfloat | depth,
|  | gl::GLint | stencil
| ) |  |

## clearBuffer() [1/3]

void globjects::Framebuffer::clearBuffer | ( | gl::GLenum | buffer,
|  | gl::GLint | drawBuffer,
|  | const glm::ivec4 & | value
| ) |  |

## clearBuffer() [2/3]

void globjects::Framebuffer::clearBuffer | ( | gl::GLenum | buffer,
|  | gl::GLint | drawBuffer,
|  | const glm::uvec4 & | value
| ) |  |

## clearBuffer() [3/3]

void globjects::Framebuffer::clearBuffer | ( | gl::GLenum | buffer,
|  | gl::GLint | drawBuffer,
|  | const glm::vec4 & | value
| ) |  |

## colorMask() [1/2]

static void globjects::Framebuffer::colorMask | ( | gl::GLboolean | red,
|  | gl::GLboolean | green,
|  | gl::GLboolean | blue,
|  | gl::GLboolean | alpha
| ) |  |

static

## colorMask() [2/2]

static void globjects::Framebuffer::colorMask | ( | const glm::bvec4 & | mask | ) |

static

## colorMaski() [1/2]

static void globjects::Framebuffer::colorMaski | ( | gl::GLuint | buffer,
|  | gl::GLboolean | red,
|  | gl::GLboolean | green,
|  | gl::GLboolean | blue,
|  | gl::GLboolean | alpha
| ) |  |

static

## colorMaski() [2/2]

static void globjects::Framebuffer::colorMaski | ( | gl::GLuint | buffer,
|  | const glm::bvec4 & | mask
| ) |  |

static

## clearColor() [1/2]

static void globjects::Framebuffer::clearColor | ( | gl::GLfloat | red,
|  | gl::GLfloat | green,
|  | gl::GLfloat | blue,
|  | gl::GLfloat | alpha
| ) |  |

static

## clearColor() [2/2]

static void globjects::Framebuffer::clearColor | ( | const glm::vec4 & | color | ) |

static

## clearDepth()

static void globjects::Framebuffer::clearDepth | ( | gl::GLclampd | depth | ) |

static

## readPixels() [1/3]

void globjects::Framebuffer::readPixels | ( | gl::GLint | x,
|  | gl::GLint | y,
|  | gl::GLsizei | width,
|  | gl::GLsizei | height,
|  | gl::GLenum | format,
|  | gl::GLenum | type,
|  | gl::GLvoid * | data = `nullptr`
| ) |  | const

## readPixels() [2/3]

void globjects::Framebuffer::readPixels | ( | const std::array< gl::GLint, 4 > & | rect,
|  | gl::GLenum | format,
|  | gl::GLenum | type,
|  | gl::GLvoid * | data = `nullptr`
| ) |  | const

## readPixels() [3/3]

void globjects::Framebuffer::readPixels | ( | gl::GLenum | readBuffer,
|  | const std::array< gl::GLint, 4 > & | rect,
|  | gl::GLenum | format,
|  | gl::GLenum | type,
|  | gl::GLvoid * | data = `nullptr`
| ) |  | const

## readPixelsToByteArray() [1/2]

std::vector< unsigned char > globjects::Framebuffer::readPixelsToByteArray | ( | const std::array< gl::GLint, 4 > & | rect,
|  | gl::GLenum | format,
|  | gl::GLenum | type
| ) |  | const

## readPixelsToByteArray() [2/2]

std::vector< unsigned char > globjects::Framebuffer::readPixelsToByteArray | ( | gl::GLenum | readBuffer,
|  | const std::array< gl::GLint, 4 > & | rect,
|  | gl::GLenum | format,
|  | gl::GLenum | type
| ) |  | const

## readPixelsToBuffer()

void globjects::Framebuffer::readPixelsToBuffer | ( | const std::array< gl::GLint, 4 > & | rect,
|  | gl::GLenum | format,
|  | gl::GLenum | type,
|  | Buffer * | pbo
| ) |  | const

## checkStatus()

gl::GLenum globjects::Framebuffer::checkStatus | ( |  | ) | const

## statusString()

std::string globjects::Framebuffer::statusString | ( |  | ) | const

## printStatus()

void globjects::Framebuffer::printStatus | ( | bool | onlyErrors = `false` | ) | const

## getAttachment()

FramebufferAttachment * globjects::Framebuffer::getAttachment | ( | gl::GLenum | attachment | ) |

## attachments()

std::vector< FramebufferAttachment * > globjects::Framebuffer::attachments | ( |  | ) |

## blit() [1/4]

void globjects::Framebuffer::blit | ( | gl::GLenum | readBuffer,
|  | const std::array< gl::GLint, 4 > & | srcRect,
|  | Framebuffer * | destFbo,
|  | gl::GLenum | drawBuffer,
|  | const std::array< gl::GLint, 4 > & | destRect,
|  | gl::ClearBufferMask | mask,
|  | gl::GLenum | filter
| ) |  | const

## blit() [2/4]

void globjects::Framebuffer::blit | ( | gl::GLenum | readBuffer,
|  | const std::array< gl::GLint, 4 > & | srcRect,
|  | Framebuffer * | destFbo,
|  | const std::vector< gl::GLenum > & | drawBuffers,
|  | const std::array< gl::GLint, 4 > & | destRect,
|  | gl::ClearBufferMask | mask,
|  | gl::GLenum | filter
| ) |  | const

## objectType()

virtual gl::GLenum globjects::Framebuffer::objectType | ( |  | ) | const

override virtual

Implements globjects::Object.

## addAttachment()

void globjects::Framebuffer::addAttachment | ( | FramebufferAttachment * | attachment | ) |

protected

## blit() [3/4]

static void globjects::Framebuffer::blit | ( | gl::GLint | srcX0,
|  | gl::GLint | srcY0,
|  | gl::GLint | srcX1,
|  | gl::GLint | srcY1,
|  | gl::GLint | destX0,
|  | gl::GLint | destY0,
|  | gl::GLint | destX1,
|  | gl::GLint | destY1,
|  | gl::ClearBufferMask | mask,
|  | gl::GLenum | filter
| ) |  |

static protected

## blit() [4/4]

static void globjects::Framebuffer::blit | ( | const std::array< gl::GLint, 4 > & | srcRect,
|  | const std::array< gl::GLint, 4 > & | destRect,
|  | gl::ClearBufferMask | mask,
|  | gl::GLenum | filter
| ) |  |

static protected

## Member Data Documentation

## m_attachments

std::map<gl::GLenum, ref_ptr<FramebufferAttachment> > globjects::Framebuffer::m_attachments

protected

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

- Framebuffer.h