X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fframebuffer.cpp;h=a0fcbc474203c5588d04e410bf4d0975c49fa983;hb=656b4577fccfb02bea747871e5ab10148f002443;hp=8dbd2d0ee93bd20940b26326c1d2aaeb0c3f25a1;hpb=3663bed18358a2399b2a8a8f7779d85e0ed81bd0;p=libs%2Fgl.git diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index 8dbd2d0e..a0fcbc47 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -52,7 +52,7 @@ void Framebuffer::update_attachment(unsigned mask) const { if(current()==this) { - bool has_color = false; + GLenum color_buf = GL_NONE; bool has_depth = false; 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; + color_buf = attch.attachment; if(attch.attachment==DEPTH_ATTACHMENT) has_depth = true; } - glDrawBuffer(has_color ? GL_FRONT : GL_NONE); + glDrawBuffer(color_buf); glDepthMask(has_depth); } else @@ -113,7 +116,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 +206,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;