X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fframebuffer.cpp;h=c4f714c64b7768e74989602ac023ce3e14655159;hb=a0649c972e30f001ee825cdd9e3981fe361b82a0;hp=3ac742bd209fd0e89c05d723c082524b4799c02c;hpb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8;p=libs%2Fgl.git diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index 3ac742bd..c4f714c6 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -1,3 +1,4 @@ +#include "error.h" #include "extension.h" #include "ext_framebuffer_blit.h" #include "ext_framebuffer_object.h" @@ -16,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); @@ -59,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); } @@ -89,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