- sequence.set_hdr(tmpl.get_hdr());
- sequence.set_alpha(tmpl.get_alpha());
- unsigned samples = min(tmpl.get_maximum_multisample(), Limits::get_global().max_samples);
- if(samples<tmpl.get_required_multisample())
- throw invalid_operation("SequenceBuilder::build");
+ map<string, Renderable *> final_renderables = renderables;
+ vector<const SequenceTemplate::Renderable *> sequences;
+ for(const SequenceTemplate::Renderable &r: tmpl.get_renderables())
+ {
+ Renderable *&ptr = final_renderables[r.slot_name];
+ if(!ptr)
+ {
+ if(r.effect_template)
+ {
+ Effect *effect = r.effect_template->create(final_renderables);
+#ifdef DEBUG
+ if(!debug_name.empty())
+ effect->set_debug_name(format("%s/%s", debug_name, r.slot_name));
+#endif
+ ptr = effect;
+ }
+ else if(r.sequence_template)
+ {
+ Sequence *seq = new Sequence;
+#ifdef DEBUG
+ if(!debug_name.empty())
+ seq->set_debug_name(format("%s/%s", debug_name, r.slot_name));
+#endif
+ ptr = seq;
+ sequences.push_back(&r);
+ }
+ else
+ throw invalid_operation("SequenceBuilder::build");
+
+ sequence.add_owned(ptr);
+ }
+ }
+
+ for(const SequenceTemplate::Renderable *s: sequences)
+ {
+ SequenceBuilder bld(*s->sequence_template);
+ for(const auto &kvp: s->sequence_renderables)
+ if(Renderable *r = get_item(final_renderables, kvp.second))
+ bld.set_renderable(kvp.first, *r);
+ bld.build(*static_cast<Sequence *>(get_item(final_renderables, s->slot_name)));
+ }