-void Framebuffer::attach(FramebufferAttachment attch, Texture2D &tex, unsigned level)
-{
- if(!id)
- throw invalid_operation("Framebuffer::attach");
-
- unsigned i = get_attachment_index(attch);
- attachments[i].set(tex, level, 0);
- update_attachment(1<<i);
- check_size();
-}
-
-void Framebuffer::attach(FramebufferAttachment attch, Texture3D &tex, unsigned layer, unsigned level)
-{
- if(!id)
- throw invalid_operation("Framebuffer::attach");
-
- unsigned i = get_attachment_index(attch);
- attachments[i].set(tex, level, layer);
- 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, TextureCube::get_face_index(face));
- update_attachment(1<<i);
- check_size();
-}
-
-void Framebuffer::detach(FramebufferAttachment attch)
-{
- if(!id)
- throw invalid_operation("Framebuffer::detach");
+ unsigned i = 0;
+ for(FrameAttachment a: format)
+ {
+ if(a==attch)
+ {
+ attachments[i].set(tex, res, level, layer);
+ dirty |= 1<<i;
+ check_size();
+ return;
+ }
+ ++i;
+ }