X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fframebuffer.cpp;h=c4f714c64b7768e74989602ac023ce3e14655159;hb=c21d4de686e7abd51b0a779af00f06ce459e18d6;hp=3d9b0133622b3bcec7590c440b8841f478217d16;hpb=7f888de83aa5398fafaa7661547ee80395377b5c;p=libs%2Fgl.git diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index 3d9b0133..c4f714c6 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -1,10 +1,4 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include "error.h" #include "extension.h" #include "ext_framebuffer_blit.h" #include "ext_framebuffer_object.h" @@ -23,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); @@ -66,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); } @@ -96,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; i