+#include "error.h"
#include "extension.h"
#include "ext_framebuffer_blit.h"
#include "ext_framebuffer_object.h"
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);
static_cast<Texture2D *>(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<TextureCube *>(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);
}
width = tex->get_width();
height = tex->get_height();
}
+ else if(i->type==GL_TEXTURE_CUBE_MAP)
+ {
+ width = static_cast<TextureCube *>(i->tex)->get_size();
+ height = width;
+ }
if(current()==this)
glViewport(0, 0, width, height);
break;
void Framebuffer::attach(FramebufferAttachment attch, Renderbuffer &rbuf)
{
if(!id)
- throw InvalidState("Can't attach to system framebuffer");
+ throw invalid_operation("Framebuffer::attach");
unsigned i = get_attachment_index(attch);
attachments[i].set(rbuf);
void Framebuffer::attach(FramebufferAttachment attch, Texture2D &tex, unsigned level)
{
if(!id)
- throw InvalidState("Can't attach to system framebuffer");
+ throw invalid_operation("Framebuffer::attach");
+
+ unsigned i = get_attachment_index(attch);
+ attachments[i].set(tex, 0, level);
+ update_attachment(1<<i);
+ check_size();
+}
+
+void Framebuffer::attach(FramebufferAttachment attch, TextureCube &tex, TextureCubeFace face, unsigned level)
+{
+ if(!id)
+ throw invalid_operation("Framebuffer::attach");
unsigned i = get_attachment_index(attch);
- attachments[i].set(tex, level);
+ attachments[i].set(tex, face, level);
update_attachment(1<<i);
check_size();
}
void Framebuffer::detach(FramebufferAttachment attch)
{
if(!id)
- throw InvalidState("Can't detach from system framebuffer");
+ throw invalid_operation("Framebuffer::detach");
unsigned i = get_attachment_index(attch);
attachments[i].clear();
level = 0;
}
-void Framebuffer::Attachment::set(Texture &t, unsigned l)
+void Framebuffer::Attachment::set(Texture &t, GLenum f, unsigned l)
{
type = t.get_target();
tex = &t;
+ cube_face = f;
level = l;
}