Distributed under the LGPL
*/
+#include "camera.h"
#include "effect.h"
#include "except.h"
#include "framebuffer.h"
namespace GL {
Pipeline::Pipeline(unsigned w, unsigned h, bool d):
+ camera(0),
width(w),
height(h),
hdr(d),
delete depth_buf;
}
+void Pipeline::set_camera(const Camera *c)
+{
+ camera = c;
+}
+
PipelinePass &Pipeline::add_pass(const Tag &tag)
{
- if(passes.count(tag.id))
+ if(passes.count(tag))
throw KeyError("Pass already exists");
- PipelinePass &pass=passes[tag.id];
+ PipelinePass &pass=passes[tag];
pass_order.push_back(tag);
return pass;
}
PipelinePass &Pipeline::get_pass(const Tag &tag)
{
- map<unsigned, PipelinePass>::iterator i=passes.find(tag.id);
+ PassMap::iterator i=passes.find(tag);
if(i==passes.end())
throw KeyError("Unknown pass");
return i->second;
const PipelinePass &Pipeline::get_pass(const Tag &tag) const
{
- map<unsigned, PipelinePass>::const_iterator i=passes.find(tag.id);
+ PassMap::const_iterator i=passes.find(tag);
if(i==passes.end())
throw KeyError("Unknown pass");
return i->second;
}
-bool Pipeline::has_pass(const Tag &tag) const
-{
- return passes.count(tag.id);
-}
-
void Pipeline::add_renderable(const Renderable &r)
{
renderables.push_back(&r);
void Pipeline::render_all() const
{
+ if(camera)
+ camera->apply();
+
if(fbo)
{
fbo->bind();
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
}
+
for(vector<Effect *>::const_iterator i=effects.begin(); i!=effects.end(); ++i)
(*i)->prepare();
for(vector<Tag>::const_iterator i=pass_order.begin(); i!=pass_order.end(); ++i)
render(*i);
for(vector<Effect *>::const_iterator i=effects.end(); i--!=effects.begin();)
(*i)->cleanup();
+
if(fbo)
Framebuffer::unbind();
+
// XXX Need two color buffer textures to handle multiple post-processors correctly
for(vector<PostProcessor *>::const_iterator i=postproc.begin(); i!=postproc.end(); ++i)
(*i)->render(*color_buf);