]> git.tdb.fi Git - libs/gl.git/blobdiff - demos/desertpillars/source/desertpillars.h
Remake the desertpillars demo using modern techniques
[libs/gl.git] / demos / desertpillars / source / desertpillars.h
diff --git a/demos/desertpillars/source/desertpillars.h b/demos/desertpillars/source/desertpillars.h
new file mode 100644 (file)
index 0000000..aac5862
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef DESERTPILLARS_H_
+#define DESERTPILLARS_H_
+
+#include <memory>
+#include <msp/core/application.h>
+#include <msp/datafile/directorysource.h>
+#include <msp/gl/camera.h>
+#include <msp/gl/objectinstance.h>
+#include <msp/gl/orderedscene.h>
+#include <msp/gl/pbrenvironmentmap.h>
+#include <msp/gl/resourcemanager.h>
+#include <msp/gl/resources.h>
+#include <msp/gl/sequence.h>
+#include <msp/gl/shadowmap.h>
+#include <msp/gl/sky.h>
+#include <msp/gl/technique.h>
+#include <msp/gl/windowview.h>
+#include <msp/graphics/display.h>
+#include <msp/graphics/glcontext.h>
+#include <msp/graphics/window.h>
+#include <msp/input/keyboard.h>
+#include <msp/time/timestamp.h>
+
+class DesertPillars: public Msp::RegisteredApplication<DesertPillars>
+{
+private:
+       struct Options
+       {
+               Msp::Graphics::WindowOptions wnd_opts;
+               Msp::Graphics::GLOptions gl_opts;
+
+               Options();
+       };
+
+       class Resources: public Msp::GL::Resources
+       {
+       private:
+               Msp::DataFile::DirectorySource source;
+
+       public:
+               Resources();
+       };
+
+       class MorphSphere: public Msp::GL::ObjectInstance
+       {
+       private:
+               Msp::GL::ProgramData shdata;
+
+       public:
+               MorphSphere(const Msp::GL::Object &o): ObjectInstance(o) { }
+
+               void set_morph(float);
+
+               virtual void setup_render(Msp::GL::Renderer &, Msp::GL::Tag) const;
+       };
+
+       Msp::Graphics::Display display;
+       Options opts;
+       Msp::Graphics::Window window;
+       Msp::Graphics::GLContext gl_ctx;
+       Msp::Input::Keyboard keyboard;
+       Resources resources;
+
+       Msp::GL::WindowView view;
+       std::unique_ptr<Msp::GL::Sequence> sequence;
+       Msp::GL::Camera camera;
+
+       std::unique_ptr<Msp::GL::Sky> sky;
+       std::unique_ptr<Msp::GL::Sequence> shadow_seq;
+       std::unique_ptr<Msp::GL::ShadowMap> shadow_map;
+       std::unique_ptr<Msp::GL::Sequence> env_seq;
+       std::unique_ptr<Msp::GL::EnvironmentMap> env_map;
+       Msp::GL::OrderedScene content;
+
+       MorphSphere sphere;
+       float sphere_morph;
+       bool sphere_frozen;
+       bool sphere_stopped;
+
+       float camera_distance;
+       Msp::Geometry::Angle<float> camera_base_height;
+       Msp::Geometry::Angle<float> camera_angle;
+       Msp::Geometry::Angle<float> sphere_angle;
+       bool camera_stopped;
+       Msp::Time::TimeStamp last_tick;
+
+public:
+       DesertPillars(int, char **);
+
+       virtual int main();
+private:
+       virtual void tick();
+
+       void key_press(unsigned);
+};
+
+#endif