]> git.tdb.fi Git - libs/gl.git/blobdiff - demos/forestpond/source/forestpond.cpp
Begin creating a new demo program
[libs/gl.git] / demos / forestpond / source / forestpond.cpp
diff --git a/demos/forestpond/source/forestpond.cpp b/demos/forestpond/source/forestpond.cpp
new file mode 100644 (file)
index 0000000..e480d20
--- /dev/null
@@ -0,0 +1,50 @@
+#include <msp/fs/dir.h>
+#include <msp/gl/sequencebuilder.h>
+#include "forestpond.h"
+
+using namespace std;
+using namespace Msp;
+
+ForestPond::ForestPond(int, char **):
+       window(display, 1920, 1080),
+       gl_device(window),
+       /* TODO InstanceArray is not compatible with ResourceManager at the moment,
+       because it requires Mesh to have its vertex format ready. */
+       resources(nullptr),
+       view(window),
+       camera(resources.get<GL::Camera>("Camera.camera"))
+{
+       window.set_title("Forest Pond");
+       window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &DesertPillars::exit), 0));
+
+       GL::SequenceBuilder seq_bld(resources.get<GL::SequenceTemplate>("Forest.seq"));
+       seq_bld.set_debug_name("Main sequence");
+       sequence.reset(seq_bld.build(view));
+
+       view.set_content(sequence.get());
+       view.set_camera(&camera);
+}
+
+int ForestPond::main()
+{
+       window.show();
+       return Application::main();
+}
+
+void ForestPond::tick()
+{
+       display.tick();
+       view.render();
+}
+
+
+ForestPond::Resources::Resources(GL::ResourceManager *rm)
+{
+       FS::Path base_dir = FS::get_sys_data_dir()/"demos"/"forestpond"/"data";
+       source.add_directory(base_dir);
+       source.add_directory(base_dir/"textures");
+       source.add_directory(base_dir/"exported");
+       add_source(source);
+
+       set_resource_manager(rm);
+}