summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
40a0024)
Originally I planned to use Pipelines to bundle objects with effects like
environmentally mapped reflection. However, that task was delegated to
effects themselves recently, so there's no longer need for passthrough
rendering in Pipeline. The render_all function was also a nuisance, as
it required Pipelines to be treated differently from other Renderables.
Passes are now stored in a list instead of a map. This allows multiple
passes with the same tag (think multipass lighting), and avoids the need
to store the pass order separately.
Pipeline::Pass &Pipeline::add_pass(const Tag &tag)
{
Pipeline::Pass &Pipeline::add_pass(const Tag &tag)
{
- Pass &pass = insert_unique(passes, tag, Pass())->second;
- pass_order.push_back(tag);
- return pass;
-}
-
-Pipeline::Pass &Pipeline::get_pass(const Tag &tag)
-{
- return get_item(passes, tag);
-}
-
-const Pipeline::Pass &Pipeline::get_pass(const Tag &tag) const
-{
- return get_item(passes, tag);
+ passes.push_back(Pass(tag));
+ return passes.back();
}
void Pipeline::add_renderable(const Renderable &r)
}
void Pipeline::add_renderable(const Renderable &r)
-void Pipeline::render(Renderer &renderer, const Tag &tag) const
+void Pipeline::render(const Tag &tag) const
- const Pass &pass = get_pass(tag);
- Bind bind_depth_test(pass.get_depth_test());
- Bind bind_blend(pass.get_blend());
- Bind bind_lighting(pass.get_lighting());
-
- for(vector<Slot>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
- if(i->passes.empty() || i->passes.count(tag))
- i->renderable->render(renderer, tag);
+ Renderer renderer(camera);
+ render(renderer, tag);
-void Pipeline::render_all() const
+void Pipeline::render(Renderer &renderer, const Tag &tag) const
- if(camera)
- camera->apply();
if(fbo)
{
Framebuffer *f = (fbo_ms ? fbo_ms : fbo);
if(fbo)
{
Framebuffer *f = (fbo_ms ? fbo_ms : fbo);
+ // XXX exception safety
f->bind();
f->clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
}
f->bind();
f->clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
}
- Renderer renderer(camera);
- for(vector<Tag>::const_iterator i=pass_order.begin(); i!=pass_order.end(); ++i)
- render(renderer, *i);
+ for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i)
+ {
+ Bind bind_depth_test(i->get_depth_test());
+ Bind bind_blend(i->get_blend());
+ Bind bind_lighting(i->get_lighting());
+
+ for(vector<Slot>::const_iterator j=renderables.begin(); j!=renderables.end(); ++j)
+ if(j->passes.empty() || j->passes.count(i->get_tag()))
+ j->renderable->render(renderer, i->get_tag());
+ }
+Pipeline::Pass::Pass(const Tag &t):
+ tag(t),
lighting(0),
depth_test(0),
blend(0)
lighting(0),
depth_test(0),
blend(0)
const Lighting *lighting;
const DepthTest *depth_test;
const Blend *blend;
public:
const Lighting *lighting;
const DepthTest *depth_test;
const Blend *blend;
public:
+ Pass(const Tag &);
+
+ const Tag &get_tag() const { return tag; }
void set_lighting(const Lighting *);
void set_depth_test(const DepthTest *);
void set_lighting(const Lighting *);
void set_depth_test(const DepthTest *);
Slot(const Renderable *);
};
Slot(const Renderable *);
};
- typedef std::map<Tag, Pass> PassMap;
+ typedef std::list<Pass> PassList;
- PassMap passes;
- std::vector<Tag> pass_order;
const Camera *camera;
std::vector<Slot> renderables;
std::vector<PostProcessor *> postproc;
const Camera *camera;
std::vector<Slot> renderables;
std::vector<PostProcessor *> postproc;
void set_camera(const Camera *);
Pass &add_pass(const Tag &tag);
void set_camera(const Camera *);
Pass &add_pass(const Tag &tag);
- Pass &get_pass(const Tag &tag);
- const Pass &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_postprocessor(PostProcessor &);
void add_renderable(const Renderable &);
void add_renderable_for_pass(const Renderable &, const Tag &);
void remove_renderable(const Renderable &);
void add_postprocessor(PostProcessor &);
+ virtual void render(const Tag &tag = Tag()) const;
virtual void render(Renderer &, const Tag &tag = Tag()) const;
virtual void render(Renderer &, const Tag &tag = Tag()) const;
- void render_all() const;
private:
void create_fbos();
private:
void create_fbos();