7 #include <gls/headercheck.hpp>
8 #include <gls/errorcheck.hpp>
9 #include <gls/objects/object.hpp>
10 #include <gls/objects/renderbuffer.hpp>
11 #include <type_traits>
12 #include <unordered_map>
18 void gen_framebuffers( GLsizei size, GLuint* name ) { glGenFramebuffers( size, name ); }
19 void delete_framebuffers( GLsizei size,
const GLuint* name ) { glDeleteFramebuffers( size, name ); }
35 return m_object.name();
49 check_gl_error( glBindFramebuffer( GL_FRAMEBUFFER, m_object.name() ) );
63 check_gl_error( glBindFramebuffer( GL_FRAMEBUFFER, 0 ) );
77 check_gl_error( glFramebufferTexture2D( GL_FRAMEBUFFER, attachment, textarget, the_texture.
name(), level ) );
89 template<GLenum Target>
91 static_assert( Target != GL_TEXTURE_CUBE_MAP,
"glFramebufferTexture cannot take non-array cubemaps" );
94 check_gl_error( glFramebufferTexture( GL_FRAMEBUFFER, attachment, the_texture.
name(), level ) );
107 template<GLenum Target>
109 static_assert( Target != GL_TEXTURE_CUBE_MAP,
"glFramebufferTextureLayer cannot take non-array cubemaps" );
112 check_gl_error( glFramebufferTextureLayer( GL_FRAMEBUFFER, attachment, the_texture.
name(), level, layer ) );
124 check_gl_error( glFramebufferTexture( GL_FRAMEBUFFER, attachment, 0, 0 ) );
142 check_gl_error( glFramebufferRenderbuffer( GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, the_renderbuffer.name() ) );
143 m_renderbuffers.emplace( attachment, std::forward<renderbuffer>( the_renderbuffer ) );
155 check_gl_error( glFramebufferRenderbuffer( GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, 0 ) );
156 m_renderbuffers.erase( attachment );
168 auto status_value = check_gl_error( glCheckFramebufferStatus( GL_FRAMEBUFFER ) );
181 return status() == GL_FRAMEBUFFER_COMPLETE;
185 std::unordered_map<GLenum, renderbuffer> m_renderbuffers;
GLuint name() const
Retrieve the OpenGL name of this texture.
Definition: texture.hpp:47
bool complete()
Check if the framebuffer is complete.
Definition: framebuffer.hpp:180
void attach_texture(GLenum attachment, GLenum textarget, const texture< GL_TEXTURE_CUBE_MAP > &the_texture, GLint level)
Attach a non-array cubemap to the given attachment.
Definition: framebuffer.hpp:75
GLenum status()
Check the status of the framebuffer.
Definition: framebuffer.hpp:166
Class encapsulating an OpenGL framebuffer object.
Definition: framebuffer.hpp:26
void remove_renderbuffer(GLenum attachment)
Clear a renderbuffer attachment.
Definition: framebuffer.hpp:153
void bind()
Bind this framebuffer to the GL_FRAMEBUFFER target.
Definition: framebuffer.hpp:48
void attach_texture_layer(GLenum attachment, const texture< Target > &the_texture, GLint level, GLint layer)
Attach a texture layer to the given attachment.
Definition: framebuffer.hpp:108
GLuint name() const
Retrieve the OpenGL name of this framebuffer.
Definition: framebuffer.hpp:34
void detach_texture(GLenum attachment)
Clear a texture attachment.
Definition: framebuffer.hpp:122
void add_renderbuffer(GLenum attachment, renderbuffer &&the_renderbuffer)
Attach a renderbuffer to the given attachment.
Definition: framebuffer.hpp:140
Class encapsulating an OpenGL renderbuffer object.
Definition: renderbuffer.hpp:23
Definition: buffer.hpp:12
Class encapsulating an OpenGL texture object.
Definition: texture.hpp:26
static void unbind()
Unbind the framebuffer currently bound to the GL_FRAMEBUFFER target.
Definition: framebuffer.hpp:62
void attach_texture(GLenum attachment, const texture< Target > &the_texture, GLint level)
Attach a texture to the given attachment.
Definition: framebuffer.hpp:90