]> git.localhorst.tv Git - blank.git/blob - src/app/Application.hpp
blank screen before doing anything serious
[blank.git] / src / app / Application.hpp
1 #ifndef BLANK_APP_APPLICATION_HPP_
2 #define BLANK_APP_APPLICATION_HPP_
3
4 #include <SDL.h>
5 #include <stack>
6
7
8 namespace blank {
9
10 class Environment;
11 class State;
12 class Window;
13
14 class Application {
15
16 public:
17         explicit Application(Environment &);
18         ~Application();
19
20         Application(const Application &) = delete;
21         Application &operator =(const Application &) = delete;
22
23         /// run until user quits
24         void Run();
25         /// evaluate a single frame of dt milliseconds
26         void Loop(int dt);
27
28         /// run for n frames
29         void RunN(size_t n);
30         /// run for t milliseconds
31         void RunT(size_t t);
32         /// run for n frames, assuming t milliseconds for each
33         void RunS(size_t n, size_t t);
34
35         /// process all events in SDL's queue
36         void HandleEvents();
37         void Handle(const SDL_Event &);
38         void Handle(const SDL_WindowEvent &);
39         /// integrate to the next step with dt milliseconds passed
40         void Update(int dt);
41         /// push the current state to display
42         void Render();
43
44         void PushState(State *);
45         State *PopState();
46         State *SwitchState(State *);
47         State &GetState();
48         bool HasState() const noexcept;
49
50 private:
51         Environment &env;
52         std::stack<State *> states;
53
54 };
55
56 }
57
58 #endif