]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/stage.cpp
Put everything in namespace Msp::DemoScene
[libs/demoscene.git] / source / stage.cpp
index dfb668852760d3526f20c2939c2f8d2b7889e88b..b6c456e96c479a6330060733b97ac2afd5533832 100644 (file)
@@ -3,10 +3,13 @@
 #include "stage.h"
 
 using namespace std;
-using namespace Msp;
+
+namespace Msp {
+namespace DemoScene {
 
 Stage::Stage():
-       pipeline(0)
+       pipeline(0),
+       last_view(0)
 { }
 
 Stage::~Stage()
@@ -14,6 +17,11 @@ Stage::~Stage()
        delete pipeline;
 }
 
+void Stage::add_things(Demo::ThingMap &things, const string &prefix)
+{
+       things[prefix+"camera"] = static_cast<GL::Placeable *>(&camera);
+}
+
 void Stage::set_camera(const GL::Camera &c)
 {
        camera.set_object_matrix(c.get_object_matrix());
@@ -43,6 +51,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);
 }
@@ -106,3 +122,6 @@ void Stage::SetCamera::Loader::camera(const string &n)
 {
        obj.camera = &demo.get_resources().get<GL::Camera>(n);
 }
+
+} // namespace DemoScene
+} // namespace Msp