- 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(const UInt16 *j=format.begin(); j!=format.end(); ++j, ++i)
+ if(*j==attch)
+ {
+ attachments[i].set(tex, level, layer);
+ dirty |= 1<<i;
+ check_size();
+ return;
+ }
+
+ throw incompatible_data("Framebuffer::attach");