]> git.localhorst.tv Git - blank.git/blob - src/app/Application.hpp
a8e0f2d00f3fdafda8df72d5533e4f86cbfe7c3c
[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/Viewport.hpp"
9 #include "../ui/Interface.hpp"
10 #include "../world/World.hpp"
11
12 #include <SDL.h>
13
14
15 namespace blank {
16
17 class Application {
18
19 public:
20         struct Config {
21                 bool vsync = true;
22                 bool doublebuf = true;
23                 int multisampling = 1;
24
25                 Interface::Config interface = Interface::Config();
26                 World::Config world = World::Config();
27         };
28
29         explicit Application(const Config &);
30
31         Application(const Application &) = delete;
32         Application &operator =(const Application &) = delete;
33
34         /// run until user quits
35         void Run();
36         /// evaluate a single frame of dt milliseconds
37         void Loop(int dt);
38
39         /// run for n frames
40         void RunN(size_t n);
41         /// run for t milliseconds
42         void RunT(size_t t);
43         /// run for n frames, assuming t milliseconds for each
44         void RunS(size_t n, size_t t);
45
46         /// process all events in SDL's queue
47         void HandleEvents();
48         void Handle(const SDL_WindowEvent &);
49         /// integrate to the next step with dt milliseconds passed
50         void Update(int dt);
51         /// push the current state to display
52         void Render();
53
54         static Entity &MakeTestEntity(World &);
55
56 private:
57         Init init;
58         Viewport viewport;
59         Assets assets;
60         FrameCounter counter;
61
62         World world;
63         Interface interface;
64
65         RandomWalk test_controller;
66
67         bool running;
68
69 };
70
71 }
72
73 #endif