X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fframebuffer.cpp;h=8a1a52316f9fa6835e685570f6357d14955389d0;hb=f4f81f1d86d50b29b9a44b237f67c6f5ad8f0523;hp=613277233a84d78258fe40c2c585cbca24cf41bb;hpb=f19366d32cc29287a2730cfba90893e407754081;p=libs%2Fgl.git diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 61327723..8a1a5231 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -16,21 +16,11 @@ framebuffer_incomplete::framebuffer_incomplete(const std::string &reason): Framebuffer::Framebuffer(bool s): - FramebufferBackend(s), - dirty(0) -{ - if(s) - { - format = get_system_format(); - get_system_size(width, height); - } -} + FramebufferBackend(s) +{ } Framebuffer::Framebuffer(): - FramebufferBackend(false), - width(0), - height(0), - dirty(0) + FramebufferBackend(false) { } Framebuffer::Framebuffer(FrameAttachment fa): @@ -47,7 +37,7 @@ Framebuffer::Framebuffer(const FrameFormat &f): 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"); @@ -107,7 +97,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)) @@ -163,7 +153,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); @@ -175,20 +165,22 @@ void Framebuffer::detach(FrameAttachment attch) } } -void Framebuffer::resize(const WindowView &view) +const Texture *Framebuffer::get_attachment(FrameAttachment attch) const { - if(id) - throw invalid_operation("Framebuffer::resize"); + if(attachments.empty()) + return 0; - width = view.get_width(); - height = view.get_height(); + int i = format.index(attch); + return (i>=0 ? attachments[i].tex : 0); } -void Framebuffer::require_complete() const +const Texture *Framebuffer::get_attachment(unsigned i) const { - if(!id) - return; + return (i