X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fframebuffer.cpp;h=01fd626598c676a7417f2772f8d72c3b4ae5b700;hb=4080571d24c1734a9188ee7fac38cf3180325adf;hp=167b403aec18e142548c9f02f775e453e71e6cb0;hpb=160e9eea29bd10034733d59507fa1bcca36be401;p=libs%2Fgl.git diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 167b403a..01fd6265 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -27,35 +27,27 @@ Framebuffer::Framebuffer(bool s): } Framebuffer::Framebuffer(): - FramebufferBackend(false) -{ - init(); -} + FramebufferBackend(false), + width(0), + height(0), + dirty(0) +{ } Framebuffer::Framebuffer(FrameAttachment fa): - FramebufferBackend(false) + Framebuffer() { - init(); set_format(fa); } Framebuffer::Framebuffer(const FrameFormat &f): - FramebufferBackend(false) + Framebuffer() { - init(); set_format(f); } -void Framebuffer::init() -{ - width = 0; - height = 0; - dirty = 0; -} - void Framebuffer::set_format(const FrameFormat &fmt) { - if(!format.empty() || !id) + if(!format.empty()) throw invalid_operation("Framebuffer::set_format"); if(fmt.empty() || !is_format_supported(fmt)) throw invalid_argument("Framebuffer::set_format"); @@ -115,7 +107,7 @@ void Framebuffer::check_size() void Framebuffer::set_attachment(FrameAttachment attch, Texture &tex, unsigned level, int layer, unsigned samples) { - if(format.empty() || !id) + if(format.empty() || attachments.empty()) throw invalid_operation("Framebuffer::attach"); if((format.get_samples()>1 && samples!=format.get_samples()) || (format.get_samples()==1 && samples)) @@ -171,7 +163,7 @@ void Framebuffer::attach_layered(FrameAttachment attch, TextureCube &tex, unsign void Framebuffer::detach(FrameAttachment attch) { - if(!id) + if(attachments.empty()) throw invalid_operation("Framebuffer::detach"); int i = format.index(attch); @@ -185,7 +177,7 @@ void Framebuffer::detach(FrameAttachment attch) void Framebuffer::resize(const WindowView &view) { - if(id) + if(attachments.empty()) throw invalid_operation("Framebuffer::resize"); width = view.get_width(); @@ -194,9 +186,6 @@ void Framebuffer::resize(const WindowView &view) void Framebuffer::require_complete() const { - if(!id) - return; - bool layered = (!attachments.empty() && attachments.front().layer<0); for(const Attachment &a: attachments) { @@ -216,12 +205,6 @@ Framebuffer &Framebuffer::system() } -Framebuffer::Attachment::Attachment(): - tex(0), - level(0), - layer(0) -{ } - void Framebuffer::Attachment::set(Texture &t, unsigned l, int z) { tex = &t;