]> git.tdb.fi Git - libs/gl.git/blob - demos/desertpillars/source/desertpillars.h
7aae1c2d903dbc52e0593950861b14152a5f94e0
[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
31                 Options();
32         };
33
34         class Resources: public Msp::GL::Resources
35         {
36         private:
37                 Msp::DataFile::DirectorySource source;
38                 Msp::GL::ResourceManager res_mgr;
39
40         public:
41                 Resources(Msp::GL::ResourceManager *);
42         };
43
44         class MorphSphere: public Msp::GL::ObjectInstance
45         {
46         private:
47                 Msp::GL::ProgramData shdata;
48
49         public:
50                 MorphSphere(const Msp::GL::Object &o): ObjectInstance(o) { }
51
52                 void set_morph(float);
53
54                 virtual void setup_render(Msp::GL::Renderer &, Msp::GL::Tag) const;
55         };
56
57         class LightFlare: public Msp::GL::ObjectInstance
58         {
59         private:
60                 Msp::GL::ProgramData shdata;
61
62         public:
63                 LightFlare(const Msp::GL::Object &, unsigned);
64
65                 virtual void setup_render(Msp::GL::Renderer &, Msp::GL::Tag) const;
66         };
67
68         Msp::Graphics::Display display;
69         Options opts;
70         Msp::Graphics::Window window;
71         Msp::GL::Device gl_device;
72         Msp::Input::Keyboard keyboard;
73         Msp::GL::ResourceManager res_mgr;
74         Resources resources;
75
76         Msp::GL::WindowView view;
77         std::unique_ptr<Msp::GL::Sequence> sequence;
78         Msp::GL::Camera camera;
79         const Msp::GL::Lighting &lighting;
80
81         std::unique_ptr<Msp::GL::Sequence> env_seq;
82         std::unique_ptr<Msp::GL::EnvironmentMap> env_map;
83         Msp::GL::OrderedScene content;
84
85         MorphSphere sphere;
86         float sphere_morph;
87         bool sphere_frozen;
88         bool sphere_stopped;
89
90         Msp::GL::DirectionalLight &sun;
91         Msp::GL::Vector3 sun_node;
92         Msp::GL::Vector3 sun_axis;
93         Msp::Geometry::Angle<float> sun_angle;
94
95         Msp::GL::PointLight &wisp;
96         Msp::GL::Color wisp_base_color;
97         Msp::Geometry::Angle<float> wisp_angle;
98         LightFlare flare;
99
100         float camera_distance;
101         Msp::Geometry::Angle<float> camera_base_height;
102         Msp::Geometry::Angle<float> camera_angle;
103         Msp::Geometry::Angle<float> sphere_angle;
104         bool camera_stopped;
105         Msp::Time::TimeStamp last_tick;
106
107 public:
108         DesertPillars(int, char **);
109
110         virtual int main();
111 private:
112         virtual void tick();
113
114         void key_press(unsigned);
115 };
116
117 #endif