X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fframebuffer.cpp;h=45eaff656b65322a5d137133061e9e2ce35924ac;hp=01fd626598c676a7417f2772f8d72c3b4ae5b700;hb=HEAD;hpb=4080571d24c1734a9188ee7fac38cf3180325adf diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 01fd6265..4f30dbb1 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): @@ -54,6 +44,7 @@ void Framebuffer::set_format(const FrameFormat &fmt) format = fmt; attachments.resize(format.size()); + format_changed(format); } void Framebuffer::update() const @@ -70,6 +61,7 @@ void Framebuffer::check_size() { unsigned w = 0; unsigned h = 0; + unsigned l = 1; if(const Texture2D *tex2d = dynamic_cast(a.tex)) { w = max(tex2d->get_width()>>a.level, 1U); @@ -84,28 +76,32 @@ void Framebuffer::check_size() { w = max(tex3d->get_width()>>a.level, 1U); h = max(tex3d->get_height()>>a.level, 1U); + l = (a.layer<0 ? tex3d->get_depth() : 1); } else if(const TextureCube *tex_cube = dynamic_cast(a.tex)) { w = max(tex_cube->get_size()>>a.level, 1U); h = w; + l = (a.layer<0 ? 6 : 1); } if(first) { width = w; height = h; + layers = l; first = false; } else { width = min(width, w); height = min(height, h); + layers = min(layers, l); } } } -void Framebuffer::set_attachment(FrameAttachment attch, Texture &tex, unsigned level, int layer, unsigned samples) +void Framebuffer::set_attachment(FrameAttachment attch, Texture &tex, Texture *res, unsigned level, int layer, unsigned samples) { if(format.empty() || attachments.empty()) throw invalid_operation("Framebuffer::attach"); @@ -118,7 +114,7 @@ void Framebuffer::set_attachment(FrameAttachment attch, Texture &tex, unsigned l { if(a==attch) { - attachments[i].set(tex, level, layer); + attachments[i].set(tex, res, level, layer); dirty |= 1<=0 ? attachments[i].tex : 0); +} + +const Texture *Framebuffer::get_attachment(unsigned i) const +{ + return (i=0 ? attachments[i].resolve : 0); +} + +const Texture *Framebuffer::get_resolve_attachment(unsigned i) const +{ + return (i