- unsigned i = get_attachment_index(attch);
- attachments[i].set(tex, level, layer);
- dirty |= 1<<i;
- check_size();
+ if((format.get_samples()>1 && samples!=format.get_samples()) || (format.get_samples()==1 && samples))
+ throw incompatible_data("Framebuffer::attach");
+
+ unsigned i = 0;
+ for(FrameAttachment a: format)
+ {
+ if(a==attch)
+ {
+ attachments[i].set(tex, level, layer);
+ dirty |= 1<<i;
+ check_size();
+ return;
+ }
+ ++i;
+ }
+
+ throw incompatible_data("Framebuffer::attach");