]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/stage.cpp
Create Stage pipeline when added to a view
[libs/demoscene.git] / source / stage.cpp
index e1ce3522753683e38d3941db0c2d2df05ab803f7..0ca5c5eec607e1f7143b54edef0eeaf10cb1ea24 100644 (file)
@@ -6,7 +6,8 @@ using namespace std;
 using namespace Msp;
 
 Stage::Stage():
-       pipeline(0)
+       pipeline(0),
+       last_view(0)
 { }
 
 Stage::~Stage()
@@ -19,11 +20,6 @@ void Stage::add_things(Demo::ThingMap &things, const string &prefix)
        things[prefix+"camera"] = static_cast<GL::Placeable *>(&camera);
 }
 
-void Stage::add_postprocessor(GL::PostProcessor &pp)
-{
-       pipeline->add_postprocessor(pp);
-}
-
 void Stage::set_camera(const GL::Camera &c)
 {
        camera.set_object_matrix(c.get_object_matrix());
@@ -53,6 +49,14 @@ void Stage::UseInView::validate() const
 
 void Stage::UseInView::start(float, float)
 {
+       if(!stage->pipeline || view!=stage->last_view)
+       {
+               stage->create_pipeline(*view);
+               if(!stage->pipeline)
+                       throw logic_error("null pipeline");
+               stage->last_view = view;
+       }
+
        view->set_camera(&stage->camera);
        view->set_content(stage->pipeline);
 }