X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fframebuffer.cpp;h=c4f714c64b7768e74989602ac023ce3e14655159;hb=afd625b06702e7a25e0730601f03955832b64e65;hp=ea28d5db2d261eeb999d1e6c05eea38b6aefe70a;hpb=6fa59eb26c39443eb44feecd17b7a8ea45411730;p=libs%2Fgl.git diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index ea28d5db..c4f714c6 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -1,11 +1,6 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include "error.h" #include "extension.h" +#include "ext_framebuffer_blit.h" #include "ext_framebuffer_object.h" #include "framebuffer.h" #include "misc.h" @@ -22,7 +17,7 @@ Framebuffer::Framebuffer(unsigned i): dirty(0) { if(id) - throw InvalidParameterValue("System framebuffer must have id 0"); + throw invalid_argument("System framebuffer must have id 0"); int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); @@ -65,6 +60,11 @@ void Framebuffer::update_attachment(unsigned mask) const static_cast(attch.tex)->allocate(attch.level); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch.attachment, attch.type, attch.tex->get_id(), attch.level); } + else if(attch.type==GL_TEXTURE_CUBE_MAP) + { + static_cast(attch.tex)->allocate(attch.level); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch.attachment, attch.cube_face, attch.tex->get_id(), attch.level); + } else glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attch.attachment, 0, 0); } @@ -95,16 +95,30 @@ void Framebuffer::check_size() width = tex->get_width(); height = tex->get_height(); } + else if(i->type==GL_TEXTURE_CUBE_MAP) + { + width = static_cast(i->tex)->get_size(); + height = width; + } if(current()==this) glViewport(0, 0, width, height); break; } } +unsigned Framebuffer::get_attachment_index(FramebufferAttachment attch) +{ + for(unsigned i=0; iid : 0)); +} + +void Framebuffer::blit_from(const Framebuffer &other, int sx, int sy, unsigned wd, unsigned ht, int dx, int dy, BufferBits bits) +{ + blit_from(other, sx, sy, sx+wd, sy+ht, dx, dy, dx+wd, dy+ht, bits, false); +} + +void Framebuffer::blit_from(const Framebuffer &other, BufferBits bits, bool filter) +{ + blit_from(other, 0, 0, other.width, other.height, 0, 0, width, height, bits, filter); +} + void Framebuffer::bind() const { if(set_current(this)) @@ -179,15 +237,6 @@ Framebuffer &Framebuffer::system() return sys_framebuf; } -unsigned Framebuffer::get_attachment_index(FramebufferAttachment attch) -{ - for(unsigned i=0; i