]> git.tdb.fi Git - libs/demoscene.git/commitdiff
Add a helper function for registering a stage with the demo
authorMikko Rasa <tdb@tdb.fi>
Wed, 22 May 2019 20:43:34 +0000 (23:43 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 22 May 2019 20:43:34 +0000 (23:43 +0300)
source/demo.cpp
source/demo.h

index 08a92b4f0d6bd925709de855a30cec20201adcf2..4cd66bd2a036d803988c18d6f195adb3bd376b60 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/time/utils.h>
 #include "demo.h"
+#include "stage.h"
 
 using namespace std;
 using namespace Msp;
@@ -27,6 +28,12 @@ Demo::~Demo()
        delete music_source;
 }
 
+void Demo::add_stage(const std::string &name, Stage &stage)
+{
+       things[name] = &stage;
+       things[name+".camera"] = static_cast<GL::Placeable *>(&stage.get_camera());
+}
+
 void Demo::set_fixed_framerate(float fps)
 {
        frame_interval = Time::sec/fps;
index e9d369bf9b337b202480b8ef1cf128a47127fb80..e2dfd6e9e6d926455827b9232036568bc68c795b 100644 (file)
@@ -13,6 +13,8 @@
 #include "action.h"
 #include "sequencer.h"
 
+class Stage;
+
 class Demo
 {
 private:
@@ -55,6 +57,9 @@ public:
        Msp::DataFile::Collection &get_resources() const { return resources; }
        Msp::GL::AnimationPlayer &get_animation_player() { return anim_player; }
 
+protected:
+       void add_stage(const std::string &, Stage &);
+public:
        template<typename T>
        T &get_thing(const std::string &);