| 1 | #ifndef ENGINE_HPP_ | 
| 2 | #define ENGINE_HPP_ | 
| 3 | 
 | 
| 4 | 
 | 
| 5 | #include <chrono> | 
| 6 | #include <atomic> | 
| 7 | #include <map> | 
| 8 | #include <thread> | 
| 9 | 
 | 
| 10 | #include "ZydecoCommon.hpp" | 
| 11 | #include "IEventQuitSubscriber.hpp" | 
| 12 | 
 | 
| 13 | 
 | 
| 14 | class IEventHandler; | 
| 15 | class IWindow; | 
| 16 | 
 | 
| 17 | 
 | 
| 18 | class Engine : public IEventQuitSubscriber | 
| 19 | { | 
| 20 | public: | 
| 21 |     Engine(IEventHandler& r_event_handler, IWindow& r_window); | 
| 22 |     ~Engine(); | 
| 23 | 
 | 
| 24 |     void OnQuitEvent() override; | 
| 25 | 
 | 
| 26 |     void Execute(); | 
| 27 | 
 | 
| 28 | protected: | 
| 29 |     IEventHandler& m_rEventHandler; | 
| 30 |     IWindow& m_rWindow; | 
| 31 | 
 | 
| 32 |     std::atomic<bool> m_aIsExiting; | 
| 33 |     std::atomic<bool> m_aSceneUpdated; | 
| 34 |     std::map<std::string, std::thread*> m_threads; | 
| 35 |     void DoEventLoop(); | 
| 36 |     void DoRenderLoop(); | 
| 37 | 
 | 
| 38 |     std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds> m_currentTime; | 
| 39 | 
 | 
| 40 |     double m_framerate; | 
| 41 |     std::chrono::microseconds m_frameRenderTimeUs; | 
| 42 |     std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds> m_frameRenderStartTime; | 
| 43 | }; | 
| 44 | 
 | 
| 45 | 
 | 
| 46 | #endif /* ENGINE_HPP_ */ | 
| 47 | 
 |