App.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef ANKI_CORE_APP_H
  2. #define ANKI_CORE_APP_H
  3. #include "anki/core/Logger.h"
  4. #include "anki/util/Singleton.h"
  5. namespace anki {
  6. class StdinListener;
  7. class Scene;
  8. class Camera;
  9. class Input;
  10. /// The core class of the engine.
  11. ///
  12. /// - It initializes the window
  13. /// - it holds the global state and thus it parses the command line arguments
  14. /// - It manipulates the main loop timer
  15. class App
  16. {
  17. public:
  18. ANKI_HAS_SLOTS(App)
  19. App()
  20. {}
  21. ~App()
  22. {}
  23. /// This method:
  24. /// - Initialize the window
  25. /// - Initialize the main renderer
  26. /// - Initialize and start the stdin listener
  27. /// - Initialize the scripting engine
  28. void init(int argc, char* argv[]);
  29. /// What it does:
  30. /// - Destroy the window
  31. /// - call exit()
  32. void quit(int code);
  33. static void printAppInfo();
  34. /// @name Accessors
  35. /// @{
  36. float getTimerTick() const
  37. {
  38. return timerTick;
  39. }
  40. float& getTimerTick()
  41. {
  42. return timerTick;
  43. }
  44. void setTimerTick(const float x)
  45. {
  46. timerTick = x;
  47. }
  48. const std::string& getSettingsPath() const
  49. {
  50. return settingsPath;
  51. }
  52. const std::string& getCachePath() const
  53. {
  54. return cachePath;
  55. }
  56. /// @}
  57. private:
  58. /// The path that holds the configuration
  59. std::string settingsPath;
  60. /// This is used as a cache
  61. std::string cachePath;
  62. float timerTick;
  63. void parseCommandLineArgs(int argc, char* argv[]);
  64. /// A slot to handle the messageHandler's signal
  65. void handleLoggerMessages(const Logger::Info& info);
  66. ANKI_SLOT(handleLoggerMessages, const Logger::Info&)
  67. void initWindow();
  68. void initDirs();
  69. void initRenderer();
  70. };
  71. typedef Singleton<App> AppSingleton;
  72. } // end namespace
  73. #endif