X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fframebuffer.cpp;h=ea28d5db2d261eeb999d1e6c05eea38b6aefe70a;hb=90a26a1740d5843b60d07d9c39d8567bfed5189c;hp=8dbd2d0ee93bd20940b26326c1d2aaeb0c3f25a1;hpb=3663bed18358a2399b2a8a8f7779d85e0ed81bd0;p=libs%2Fgl.git diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index 8dbd2d0e..ea28d5db 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -52,8 +52,7 @@ void Framebuffer::update_attachment(unsigned mask) const { if(current()==this) { - bool has_color = false; - bool has_depth = false; + GLenum color_buf = GL_NONE; for(unsigned i=0; iget_id()); else if(attch.type==GL_TEXTURE_2D) + { + static_cast(attch.tex)->allocate(attch.level); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch.attachment, attch.type, attch.tex->get_id(), attch.level); + } else glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attch.attachment, 0, 0); } if(attch.attachment>=COLOR_ATTACHMENT0 && attch.attachment<=COLOR_ATTACHMENT3) - has_color = true; - if(attch.attachment==DEPTH_ATTACHMENT) - has_depth = true; + color_buf = attch.attachment; } - glDrawBuffer(has_color ? GL_FRONT : GL_NONE); - glDepthMask(has_depth); + glDrawBuffer(color_buf); } else dirty |= mask; @@ -113,7 +112,7 @@ void Framebuffer::attach(FramebufferAttachment attch, Renderbuffer &rbuf) check_size(); } -void Framebuffer::attach(FramebufferAttachment attch, Texture2D &tex, int level) +void Framebuffer::attach(FramebufferAttachment attch, Texture2D &tex, unsigned level) { if(!id) throw InvalidState("Can't attach to system framebuffer"); @@ -203,7 +202,7 @@ void Framebuffer::Attachment::set(Renderbuffer &r) level = 0; } -void Framebuffer::Attachment::set(Texture &t, int l) +void Framebuffer::Attachment::set(Texture &t, unsigned l) { type = t.get_target(); tex = &t;