]> git.localhorst.tv Git - blank.git/blob - src/app/Runtime.hpp
036b8dbfc635ef9078454036113626b2b79266b0
[blank.git] / src / app / Runtime.hpp
1 #ifndef BLANK_RUNTIME_HPP_
2 #define BLANK_RUNTIME_HPP_
3
4 #include "../ui/Interface.hpp"
5 #include "../world/World.hpp"
6
7 #include <cstddef>
8
9
10 namespace blank {
11
12 /// Parse and interpret arguemnts, then set up the environment and execute.
13 class Runtime {
14
15 public:
16         enum Mode {
17                 /// default behaviour: run until user quits, dynamic timesteps
18                 NORMAL,
19                 /// quit after n frames
20                 FRAME_LIMIT,
21                 /// quit after n milliseconds
22                 TIME_LIMIT,
23                 /// quit after n frames, use fixed timestap
24                 FIXED_FRAME_LIMIT,
25                 /// display error message and quit with failure
26                 ERROR,
27         };
28
29         struct Config {
30                 bool vsync = true;
31                 bool doublebuf = true;
32                 int multisampling = 1;
33
34                 Interface::Config interface = Interface::Config();
35                 World::Config world = World::Config();
36         };
37
38         Runtime() noexcept;
39
40         void ReadArgs(int argc, const char *const *argv);
41
42         int Execute();
43
44 private:
45         const char *name;
46         Mode mode;
47         std::size_t n;
48         std::size_t t;
49         Config config;
50
51 };
52
53 }
54
55 #endif