]> git.localhorst.tv Git - blank.git/blob - src/app/Application.hpp
97cac73805b5ddad01c194e2f22d023830869d36
[blank.git] / src / app / Application.hpp
1 #ifndef BLANK_APP_APPLICATION_HPP_
2 #define BLANK_APP_APPLICATION_HPP_
3
4 #include "Assets.hpp"
5 #include "FrameCounter.hpp"
6 #include "init.hpp"
7 #include "RandomWalk.hpp"
8 #include "../graphics/BlendedSprite.hpp"
9 #include "../graphics/BlockLighting.hpp"
10 #include "../graphics/Camera.hpp"
11 #include "../graphics/DirectionalLighting.hpp"
12 #include "../ui/Interface.hpp"
13 #include "../world/World.hpp"
14
15 #include <SDL.h>
16
17
18 namespace blank {
19
20 class Application {
21
22 public:
23         struct Config {
24                 bool vsync = true;
25                 bool doublebuf = true;
26                 int multisampling = 1;
27
28                 Interface::Config interface = Interface::Config();
29                 World::Config world = World::Config();
30         };
31
32         explicit Application(const Config &);
33
34         Application(const Application &) = delete;
35         Application &operator =(const Application &) = delete;
36
37         /// run until user quits
38         void Run();
39         /// evaluate a single frame of dt milliseconds
40         void Loop(int dt);
41
42         /// run for n frames
43         void RunN(size_t n);
44         /// run for t milliseconds
45         void RunT(size_t t);
46         /// run for n frames, assuming t milliseconds for each
47         void RunS(size_t n, size_t t);
48
49         /// process all events in SDL's queue
50         void HandleEvents();
51         void Handle(const SDL_WindowEvent &);
52         /// integrate to the next step with dt milliseconds passed
53         void Update(int dt);
54         /// push the current state to display
55         void Render();
56
57         static Entity &MakeTestEntity(World &);
58
59 private:
60         InitSDL init_sdl;
61         InitIMG init_img;
62         InitTTF init_ttf;
63         InitGL init_gl;
64         Window window;
65         GLContext ctx;
66         InitGLEW init_glew;
67         Assets assets;
68         FrameCounter counter;
69
70         BlockLighting chunk_prog;
71         DirectionalLighting entity_prog;
72         BlendedSprite sprite_prog;
73
74         Camera cam;
75         World world;
76         Interface interface;
77
78         RandomWalk test_controller;
79
80         bool running;
81
82 };
83
84 }
85
86 #endif