Loading...
Searching...
No Matches
Framebuffer.h
Go to the documentation of this file.
#pragma once
#include <map>
#include <string>
#include <vector>
#include <array>
#include <glm/fwd.hpp>
#include <globjects/base/ref_ptr.h>
#include <globjects/globjects_api.h>
#include <globjects/Object.h>
namespace globjects
{
class FramebufferAttachment;
class Renderbuffer;
class Texture;
class Buffer;
class GLOBJECTS_API Framebuffer : public Object
{
public:
enum class BindlessImplementation
{
DirectStateAccessARB
, DirectStateAccessEXT
, Legacy
};
static void hintBindlessImplementation(BindlessImplementation impl);
public:
Framebuffer();
static Framebuffer * fromId(gl::GLuint id);
static Framebuffer * defaultFBO();
virtual void accept(ObjectVisitor& visitor) override;
void bind() const;
void bind(gl::GLenum target) const;
static void unbind();
static void unbind(gl::GLenum target);
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);
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);
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;
protected:
Framebuffer(IDResource * resource);
virtual ~Framebuffer();
void addAttachment(FramebufferAttachment * attachment);
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:
std::map<gl::GLenum, ref_ptr<FramebufferAttachment>> m_attachments;
};
} // namespace globjects
Object.h
globjects::Buffer
Wrapper for OpenGL buffer objects.
Definition Buffer.h:36
globjects::FramebufferAttachment
Wraps attachments to a FrameBufferObject.
Definition FramebufferAttachment.h:30
globjects::Framebuffer
Enables creation of arbitrary render targets that are not directly drawn on the screen.
Definition Framebuffer.h:47
globjects::Framebuffer::clearBufferiv
void clearBufferiv(gl::GLenum buffer, gl::GLint drawBuffer, const gl::GLint *value)
globjects::Framebuffer::readPixelsToByteArray
std::vector< unsigned char > readPixelsToByteArray(gl::GLenum readBuffer, const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type) const
globjects::Framebuffer::BindlessImplementation
BindlessImplementation
Definition Framebuffer.h:50
globjects::Framebuffer::getAttachmentParameter
gl::GLint getAttachmentParameter(gl::GLenum attachment, gl::GLenum pname) const
globjects::Framebuffer::readPixelsToByteArray
std::vector< unsigned char > readPixelsToByteArray(const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type) const
globjects::Framebuffer::blit
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
globjects::Framebuffer::fromId
static Framebuffer * fromId(gl::GLuint id)
globjects::Framebuffer::readPixels
void readPixels(const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type, gl::GLvoid *data=nullptr) const
globjects::Framebuffer::clearBufferfv
void clearBufferfv(gl::GLenum buffer, gl::GLint drawBuffer, const gl::GLfloat *value)
globjects::Framebuffer::setDrawBuffers
void setDrawBuffers(gl::GLsizei n, const gl::GLenum *modes) const
globjects::Framebuffer::~Framebuffer
virtual ~Framebuffer()
globjects::Framebuffer::colorMask
static void colorMask(gl::GLboolean red, gl::GLboolean green, gl::GLboolean blue, gl::GLboolean alpha)
globjects::Framebuffer::readPixels
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
globjects::Framebuffer::blit
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)
globjects::Framebuffer::clearBufferfi
void clearBufferfi(gl::GLenum buffer, gl::GLint drawBuffer, gl::GLfloat depth, gl::GLint stencil)
globjects::Framebuffer::setDrawBuffer
void setDrawBuffer(gl::GLenum mode) const
globjects::Framebuffer::readPixelsToBuffer
void readPixelsToBuffer(const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type, Buffer *pbo) const
globjects::Framebuffer::blit
static void blit(const std::array< gl::GLint, 4 > &srcRect, const std::array< gl::GLint, 4 > &destRect, gl::ClearBufferMask mask, gl::GLenum filter)
globjects::Framebuffer::attachTextureLayer
void attachTextureLayer(gl::GLenum attachment, Texture *texture, gl::GLint level=0, gl::GLint layer=0)
globjects::Framebuffer::colorMaski
static void colorMaski(gl::GLuint buffer, gl::GLboolean red, gl::GLboolean green, gl::GLboolean blue, gl::GLboolean alpha)
globjects::Framebuffer::clearColor
static void clearColor(gl::GLfloat red, gl::GLfloat green, gl::GLfloat blue, gl::GLfloat alpha)
globjects::Framebuffer::attachTexture
void attachTexture(gl::GLenum attachment, Texture *texture, gl::GLint level=0)
globjects::Framebuffer::Framebuffer
Framebuffer()
globjects::Framebuffer::checkStatus
gl::GLenum checkStatus() const
globjects::Framebuffer::Framebuffer
Framebuffer(IDResource *resource)
globjects::Framebuffer::setParameter
void setParameter(gl::GLenum pname, gl::GLint param)
globjects::Framebuffer::unbind
static void unbind(gl::GLenum target)
globjects::Framebuffer::detach
bool detach(gl::GLenum attachment)
globjects::Framebuffer::accept
virtual void accept(ObjectVisitor &visitor) override
globjects::Framebuffer::attachRenderBuffer
void attachRenderBuffer(gl::GLenum attachment, Renderbuffer *renderBuffer)
globjects::Framebuffer::objectType
virtual gl::GLenum objectType() const override
globjects::Framebuffer::clearDepth
static void clearDepth(gl::GLclampd depth)
globjects::Framebuffer::hintBindlessImplementation
static void hintBindlessImplementation(BindlessImplementation impl)
globjects::Framebuffer::clearBuffer
void clearBuffer(gl::GLenum buffer, gl::GLint drawBuffer, const glm::ivec4 &value)
globjects::Framebuffer::setDrawBuffers
void setDrawBuffers(const std::vector< gl::GLenum > &modes) const
globjects::Framebuffer::clearColor
static void clearColor(const glm::vec4 &color)
globjects::Framebuffer::statusString
std::string statusString() const
globjects::Framebuffer::getAttachment
FramebufferAttachment * getAttachment(gl::GLenum attachment)
globjects::Framebuffer::m_attachments
std::map< gl::GLenum, ref_ptr< FramebufferAttachment > > m_attachments
Definition Framebuffer.h:138
globjects::Framebuffer::attachments
std::vector< FramebufferAttachment * > attachments()
globjects::Framebuffer::blit
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
globjects::Framebuffer::printStatus
void printStatus(bool onlyErrors=false) const
globjects::Framebuffer::clearBuffer
void clearBuffer(gl::GLenum buffer, gl::GLint drawBuffer, const glm::uvec4 &value)
globjects::Framebuffer::colorMaski
static void colorMaski(gl::GLuint buffer, const glm::bvec4 &mask)
globjects::Framebuffer::bind
void bind() const
globjects::Framebuffer::unbind
static void unbind()
globjects::Framebuffer::setReadBuffer
void setReadBuffer(gl::GLenum mode) const
globjects::Framebuffer::colorMask
static void colorMask(const glm::bvec4 &mask)
globjects::Framebuffer::clear
void clear(gl::ClearBufferMask mask)
globjects::Framebuffer::clearBufferuiv
void clearBufferuiv(gl::GLenum buffer, gl::GLint drawBuffer, const gl::GLuint *value)
globjects::Framebuffer::clearBuffer
void clearBuffer(gl::GLenum buffer, gl::GLint drawBuffer, const glm::vec4 &value)
globjects::Framebuffer::readPixels
void readPixels(gl::GLenum readBuffer, const std::array< gl::GLint, 4 > &rect, gl::GLenum format, gl::GLenum type, gl::GLvoid *data=nullptr) const
globjects::Framebuffer::bind
void bind(gl::GLenum target) const
globjects::Framebuffer::defaultFBO
static Framebuffer * defaultFBO()
globjects::Framebuffer::addAttachment
void addAttachment(FramebufferAttachment *attachment)
globjects::Object
Superclass of all wrapped OpenGL objects.
Definition Object.h:27
globjects::ObjectVisitor
Implements a Visitor Pattern to iterate over all tracked globjects objects.
Definition ObjectVisitor.h:30
globjects::Renderbuffer
Encapsulates OpenGL render buffer objects.
Definition Renderbuffer.h:19
globjects::Texture
Wraps OpenGL texture objects. A Texture provides both interfaces to bind them for the OpenGL pipeline...
Definition Texture.h:31
globjects
Contains all the classes that wrap OpenGL functionality.
ref_ptr.h