]> git.tdb.fi Git - libs/gl.git/blob - demos/desertpillars/source/desertpillars.h
352b8c2c0b2b09fdaa496e7191bcf6d1cefc80cb
[libs/gl.git] / demos / desertpillars / source / desertpillars.h
1 #ifndef DESERTPILLARS_H_
2 #define DESERTPILLARS_H_
3
4 #include <memory>
5 #include <msp/core/application.h>
6 #include <msp/datafile/directorysource.h>
7 #include <msp/gl/camera.h>
8 #include <msp/gl/device.h>
9 #include <msp/gl/environmentmap.h>
10 #include <msp/gl/objectinstance.h>
11 #include <msp/gl/orderedscene.h>
12 #include <msp/gl/resourcemanager.h>
13 #include <msp/gl/resources.h>
14 #include <msp/gl/sequence.h>
15 #include <msp/gl/shadowmap.h>
16 #include <msp/gl/sky.h>
17 #include <msp/gl/technique.h>
18 #include <msp/gl/windowview.h>
19 #include <msp/graphics/display.h>
20 #include <msp/graphics/window.h>
21 #include <msp/input/keyboard.h>
22 #include <msp/time/timestamp.h>
23
24 class DesertPillars: public Msp::RegisteredApplication<DesertPillars>
25 {
26 private:
27         struct Options
28         {
29                 Msp::Graphics::WindowOptions wnd_opts;
30                 Msp::Graphics::GLOptions gl_opts;
31
32                 Options();
33         };
34
35         class Resources: public Msp::GL::Resources
36         {
37         private:
38                 Msp::DataFile::DirectorySource source;
39                 Msp::GL::ResourceManager res_mgr;
40
41         public:
42                 Resources(Msp::GL::ResourceManager *);
43         };
44
45         class MorphSphere: public Msp::GL::ObjectInstance
46         {
47         private:
48                 Msp::GL::ProgramData shdata;
49
50         public:
51                 MorphSphere(const Msp::GL::Object &o): ObjectInstance(o) { }
52
53                 void set_morph(float);
54
55                 virtual void setup_render(Msp::GL::Renderer &, Msp::GL::Tag) const;
56         };
57
58         class LightFlare: public Msp::GL::ObjectInstance
59         {
60         private:
61                 Msp::GL::ProgramData shdata;
62
63         public:
64                 LightFlare(const Msp::GL::Object &, unsigned);
65
66                 virtual void setup_render(Msp::GL::Renderer &, Msp::GL::Tag) const;
67         };
68
69         Msp::Graphics::Display display;
70         Options opts;
71         Msp::Graphics::Window window;
72         Msp::GL::Device gl_device;
73         Msp::Input::Keyboard keyboard;
74         Msp::GL::ResourceManager res_mgr;
75         Resources resources;
76
77         Msp::GL::WindowView view;
78         std::unique_ptr<Msp::GL::Sequence> sequence;
79         Msp::GL::Camera camera;
80         const Msp::GL::Lighting &lighting;
81
82         std::unique_ptr<Msp::GL::Sequence> env_seq;
83         std::unique_ptr<Msp::GL::EnvironmentMap> env_map;
84         Msp::GL::OrderedScene content;
85
86         MorphSphere sphere;
87         float sphere_morph;
88         bool sphere_frozen;
89         bool sphere_stopped;
90
91         Msp::GL::DirectionalLight &sun;
92         Msp::GL::Vector3 sun_node;
93         Msp::GL::Vector3 sun_axis;
94         Msp::Geometry::Angle<float> sun_angle;
95
96         Msp::GL::PointLight &wisp;
97         Msp::GL::Color wisp_base_color;
98         Msp::Geometry::Angle<float> wisp_angle;
99         LightFlare flare;
100
101         float camera_distance;
102         Msp::Geometry::Angle<float> camera_base_height;
103         Msp::Geometry::Angle<float> camera_angle;
104         Msp::Geometry::Angle<float> sphere_angle;
105         bool camera_stopped;
106         Msp::Time::TimeStamp last_tick;
107
108 public:
109         DesertPillars(int, char **);
110
111         virtual int main();
112 private:
113         virtual void tick();
114
115         void key_press(unsigned);
116 };
117
118 #endif