]> git.tdb.fi Git - libs/demoscene.git/blob - source/stage.cpp
cbe576fa24ba566d2e33bcb2e04201c8c40be027
[libs/demoscene.git] / source / stage.cpp
1 #include <msp/gl/view.h>
2 #include "demo.h"
3 #include "stage.h"
4
5 using namespace std;
6 using namespace Msp;
7
8 Stage::Stage():
9         pipeline(0)
10 { }
11
12 Stage::~Stage()
13 {
14         delete pipeline;
15 }
16
17
18 Stage::UseInView::UseInView():
19         view(0),
20         stage(0)
21 { }
22
23 Stage::UseInView::UseInView(GL::View &v, Stage &s):
24         view(&v),
25         stage(&s)
26 { }
27
28 void Stage::UseInView::validate() const
29 {
30         if(!view)
31                 throw logic_error("null view");
32         if(!stage)
33                 throw logic_error("null stage");
34 }
35
36 void Stage::UseInView::start(float, float)
37 {
38         view->set_camera(&stage->camera_control.get_camera());
39         view->set_content(stage->pipeline);
40 }
41
42
43 Stage::UseInView::Loader::Loader(UseInView &u, Demo &d):
44         DataFile::DerivedObjectLoader<UseInView, Action::Loader>(u, d)
45 {
46         add("view", &Loader::view);
47         add("stage", &Loader::stage);
48 }
49
50 void Stage::UseInView::Loader::view(const string &n)
51 {
52         obj.view = &demo.get_thing<GL::View>(n);
53 }
54
55 void Stage::UseInView::Loader::stage(const string &n)
56 {
57         obj.stage = &demo.get_thing<Stage>(n);
58 }