2 #ifndef KJY_OBJECT_ORIENTED_OPENGL_FRAMEBUFFER_HPP_ 3 #define KJY_OBJECT_ORIENTED_OPENGL_FRAMEBUFFER_HPP_ 8 #include "../OOOGL_Core.hpp" 9 #include "fbo_interface.hpp" 10 #include "Texture.hpp" 11 #include "Renderbuffer.hpp" 12 #include "../Core_Utilities.hpp" 19 glGenFramebuffers(1, getIdPtr());
20 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAttach);
25 void attachRenderbuffer(
const Renderbuffer& renderbuffer, GLenum attachment,
bool clobber =
false);
26 void attach(
const SimpleTexture2D& tex2d, GLenum attachment,
int level = 0,
bool clobber =
false);
27 void attach(
const TextureArray& texarray, GLenum attachment,
int layer,
int level = 0);
28 void dettach(GLenum attachment);
30 void setDrawBuffers(
const std::vector<GLenum>& bufs,
bool clobber =
false);
31 void setDrawBuffers(GLsizei n,
const GLenum *bufs,
bool clobber =
false);
33 void setSingleDrawMode(GLenum mode);
34 void setSingleReadMode(GLenum mode);
36 void setDefaultWidth(GLint width);
37 GLint getDefaultWidth()
const {
return(default_width);}
38 void setDefaultHeight(GLint height);
39 GLint getDefaultHeight()
const {
return(default_height);}
40 void setDefaultLayers(GLint layers);
41 GLint getDefaultLayers()
const {
return(default_layers);}
42 void setDefaultSamples(GLint samples);
43 GLint getDefaultSamples()
const {
return(default_samples);}
44 void setDefaultFixedSampleLocations(GLint param);
45 GLint getDefaultFixedSampleLocations()
const {
return(default_fixed_sample_locations);}
48 CHECKED_GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, getNameDirect()));
50 void bindDraw()
const {
51 CHECKED_GL_CALL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, getNameDirect()));
53 void bindRead()
const {
54 CHECKED_GL_CALL(glBindFramebuffer(GL_READ_FRAMEBUFFER, getNameDirect()));
57 GLenum getStatus(GLenum target = GL_FRAMEBUFFER)
const {
58 return(glCheckNamedFramebufferStatus(getNameDirect(), GL_FRAMEBUFFER));
61 bool isComplete()
const {
62 return(getStatus() == GL_FRAMEBUFFER_COMPLETE);
65 static size_t get_stashed_id_count(){
return(stashed_read_draw_ids.size());}
67 static void push_framebuffer_state();
69 static void pop_framebuffer_state();
77 virtual const char* what()
const noexcept
override{
return(_whatstr.c_str());}
79 const std::string _whatstr;
87 GLint default_width = -1;
88 GLint default_height = -1;
89 GLint default_layers = -1;
90 GLint default_samples = -1;
91 GLint default_fixed_sample_locations = -1;
94 static void _destroyFBO(
const GLuint*
self){
95 glDeleteFramebuffers(1,
self);
97 static std::stack<std::pair<GLint, GLint>> stashed_read_draw_ids;
Definition: Framebuffer.hpp:74
Definition: Texture.hpp:60
Definition: Texture.hpp:88
Definition: Framebuffer.hpp:16
Definition: OOOGL_Core.hpp:144
Definition: OOOGL_Core.hpp:105
Definition: Renderbuffer.hpp:16
Definition: Core_Utilities.hpp:299
Definition: fbo_interface.hpp:10
Definition: Core_Utilities.cpp:3