]> git.tdb.fi Git - libs/gl.git/blob - demos/forestpond/source/forestpond.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / demos / forestpond / source / forestpond.cpp
1 #include <msp/fs/dir.h>
2 #include <msp/gl/sequencebuilder.h>
3 #include "forestpond.h"
4
5 using namespace std;
6 using namespace Msp;
7
8 ForestPond::ForestPond(int, char **):
9         window(display, 1920, 1080),
10         gl_device(window),
11         /* TODO InstanceArray is not compatible with ResourceManager at the moment,
12         because it requires Mesh to have its vertex format ready. */
13         resources(nullptr),
14         view(window),
15         camera(resources.get<GL::Camera>("Camera.camera"))
16 {
17         window.set_title("Forest Pond");
18         window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &ForestPond::exit), 0));
19
20         GL::SequenceBuilder seq_bld(resources.get<GL::SequenceTemplate>("Forest.seq"));
21         seq_bld.set_debug_name("Main sequence");
22         sequence.reset(seq_bld.build(view));
23
24         view.set_content(sequence.get());
25         view.set_camera(&camera);
26 }
27
28 int ForestPond::main()
29 {
30         window.show();
31         return Application::main();
32 }
33
34 void ForestPond::tick()
35 {
36         display.tick();
37         view.render();
38 }
39
40
41 ForestPond::Resources::Resources(GL::ResourceManager *rm)
42 {
43         FS::Path base_dir = FS::get_sys_data_dir()/"demos"/"forestpond"/"data";
44         source.add_directory(base_dir);
45         source.add_directory(base_dir/"textures");
46         source.add_directory(base_dir/"exported");
47         add_source(source);
48
49         set_resource_manager(rm);
50 }