void Pipeline::add_renderable(const Renderable &r)
{
+ for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
+ if(i->renderable==&r)
+ {
+ i->passes.clear();
+ return;
+ }
+
+ renderables.push_back(&r);
+}
+
+void Pipeline::add_renderable_for_pass(const Renderable &r, const Tag &tag)
+{
+ for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
+ if(i->renderable==&r)
+ {
+ i->passes.insert(tag);
+ return;
+ }
+
renderables.push_back(&r);
+ renderables.back().passes.insert(tag);
+}
+
+void Pipeline::remove_renderable(const Renderable &r)
+{
+ for(vector<Slot>::iterator i=renderables.begin(); i!=renderables.end(); ++i)
+ if(i->renderable==&r)
+ {
+ renderables.erase(i);
+ return;
+ }
}
void Pipeline::add_effect(Effect &e)
for(vector<Effect *>::const_iterator i=pass.effects.begin(); i!=pass.effects.end(); ++i)
(*i)->prepare();
- for(vector<const Renderable *>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
- (*i)->render(tag);
+ for(vector<Slot>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
+ if(i->passes.empty() || i->passes.count(tag))
+ i->renderable->render(tag);
for(vector<Effect *>::const_iterator i=pass.effects.end(); i!=pass.effects.begin();)
(*--i)->cleanup();
(*i)->render(*color_buf);
}
+
+Pipeline::Slot::Slot(const Renderable *r):
+ renderable(r)
+{ }
+
} // namespace GL
} // namespace Msp
#define MSP_GL_PIPELINE_H_
#include <map>
+#include <set>
#include "pipelinepass.h"
#include "renderable.h"
class Pipeline: public Renderable
{
private:
+ struct Slot
+ {
+ const Renderable *renderable;
+ std::set<Tag> passes;
+
+ Slot(const Renderable *);
+ };
+
typedef std::map<Tag, PipelinePass> PassMap;
PassMap passes;
std::vector<Tag> pass_order;
const Camera *camera;
- std::vector<const Renderable *> renderables;
+ std::vector<Slot> renderables;
std::vector<Effect *> effects;
std::vector<PostProcessor *> postproc;
unsigned width;
const PipelinePass &get_pass(const Tag &tag) const;
void add_renderable(const Renderable &);
+ void add_renderable_for_pass(const Renderable &, const Tag &);
+ void remove_renderable(const Renderable &);
void add_effect(Effect &);
void add_postprocessor(PostProcessor &);