]> git.tdb.fi Git - libs/gl.git/blob - demos/desertpillars/source/desertpillars.h
Use image-based lighting in the entire desert pillars scene
[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/environmentmap.h>
9 #include <msp/gl/objectinstance.h>
10 #include <msp/gl/orderedscene.h>
11 #include <msp/gl/resourcemanager.h>
12 #include <msp/gl/resources.h>
13 #include <msp/gl/sequence.h>
14 #include <msp/gl/shadowmap.h>
15 #include <msp/gl/sky.h>
16 #include <msp/gl/technique.h>
17 #include <msp/gl/windowview.h>
18 #include <msp/graphics/display.h>
19 #include <msp/graphics/glcontext.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
40         public:
41                 Resources();
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         Msp::Graphics::Display display;
58         Options opts;
59         Msp::Graphics::Window window;
60         Msp::Graphics::GLContext gl_ctx;
61         Msp::Input::Keyboard keyboard;
62         Resources resources;
63
64         Msp::GL::WindowView view;
65         std::unique_ptr<Msp::GL::Sequence> sequence;
66         Msp::GL::Camera camera;
67
68         std::unique_ptr<Msp::GL::Sky> sky;
69         std::unique_ptr<Msp::GL::Sequence> shadow_seq;
70         std::unique_ptr<Msp::GL::ShadowMap> shadow_map;
71         std::unique_ptr<Msp::GL::Sequence> env_seq;
72         std::unique_ptr<Msp::GL::EnvironmentMap> env_map;
73         std::unique_ptr<Msp::GL::EnvironmentMap> global_env;
74         Msp::GL::OrderedScene content;
75
76         MorphSphere sphere;
77         float sphere_morph;
78         bool sphere_frozen;
79         bool sphere_stopped;
80
81         float camera_distance;
82         Msp::Geometry::Angle<float> camera_base_height;
83         Msp::Geometry::Angle<float> camera_angle;
84         Msp::Geometry::Angle<float> sphere_angle;
85         bool camera_stopped;
86         Msp::Time::TimeStamp last_tick;
87
88 public:
89         DesertPillars(int, char **);
90
91         virtual int main();
92 private:
93         virtual void tick();
94
95         void key_press(unsigned);
96 };
97
98 #endif