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;
throw invalid_operation("Framebuffer::attach");
unsigned i = get_attachment_index(attch);
- attachments[i].set(tex, level);
+ 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, face, level);
update_attachment(1<<i);
check_size();
}
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;
}