X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.hpp;h=359599ef73750de04c0ee3de16c489690114a005;hb=d2f4c8720ae2326fac4203fa4984d835e875b355;hp=bae8435a0084811151300e825b9c5fec402f35d8;hpb=afd253b2dd10fdf2d4655d3d4a5766e6aa8c1a2c;p=blank.git diff --git a/src/app/Application.hpp b/src/app/Application.hpp index bae8435..359599e 100644 --- a/src/app/Application.hpp +++ b/src/app/Application.hpp @@ -8,22 +8,27 @@ namespace blank { class Environment; +class HeadlessEnvironment; class State; class Window; -class Application { +class HeadlessApplication { public: - explicit Application(Environment &); - ~Application(); + explicit HeadlessApplication(HeadlessEnvironment &); + ~HeadlessApplication(); - Application(const Application &) = delete; - Application &operator =(const Application &) = delete; + void PushState(State *); + State *PopState(); + State *SwitchState(State *); + State &GetState(); + void CommitStates(); + bool HasState() const noexcept; - /// run until user quits + /// run until out of states void Run(); /// evaluate a single frame of dt milliseconds - void Loop(int dt); + virtual void Loop(int dt); /// run for n frames void RunN(size_t n); @@ -32,6 +37,31 @@ public: /// run for n frames, assuming t milliseconds for each void RunS(size_t n, size_t t); + /// process all events in SDL's queue + void HandleEvents(); + void Handle(const SDL_Event &); + /// integrate to the next step with dt milliseconds passed + void Update(int dt); + +private: + HeadlessEnvironment &env; + std::stack states; + +}; + + +class Application +: public HeadlessApplication { + +public: + explicit Application(Environment &); + ~Application(); + + Application(const Application &) = delete; + Application &operator =(const Application &) = delete; + + void Loop(int dt) override; + /// process all events in SDL's queue void HandleEvents(); void Handle(const SDL_Event &); @@ -41,15 +71,8 @@ public: /// push the current state to display void Render(); - void PushState(State *); - State *PopState(); - State *SwitchState(State *); - State &GetState(); - bool HasState() const noexcept; - private: Environment &env; - std::stack states; };