App.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef ANKI_CORE_APP_H
  2. #define ANKI_CORE_APP_H
  3. #include "anki/Config.h"
  4. #include "anki/util/Singleton.h"
  5. #include "anki/util/StringList.h"
  6. #if ANKI_OS == ANKI_OS_ANDROID
  7. # include <android_native_app_glue.h>
  8. #endif
  9. namespace anki {
  10. #if ANKI_OS == ANKI_OS_ANDROID
  11. extern android_app* gAndroidApp;
  12. #endif
  13. /// The core class of the engine.
  14. ///
  15. /// - It initializes the window
  16. /// - it holds the global state and thus it parses the command line arguments
  17. /// - It manipulates the main loop timer
  18. class App
  19. {
  20. public:
  21. App()
  22. {}
  23. ~App()
  24. {}
  25. /// Initialize the app
  26. void init();
  27. /// @name Accessors
  28. /// @{
  29. F32 getTimerTick() const
  30. {
  31. return timerTick;
  32. }
  33. F32& getTimerTick()
  34. {
  35. return timerTick;
  36. }
  37. void setTimerTick(const F32 x)
  38. {
  39. timerTick = x;
  40. }
  41. const std::string& getSettingsPath() const
  42. {
  43. return settingsPath;
  44. }
  45. const std::string& getCachePath() const
  46. {
  47. return cachePath;
  48. }
  49. /// @}
  50. /// What it does:
  51. /// - Destroy the window
  52. /// - call exit()
  53. void quit(int code);
  54. /// Run the main loop
  55. void mainLoop();
  56. static void printAppInfo();
  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. F32 timerTick;
  63. void initDirs();
  64. };
  65. typedef Singleton<App> AppSingleton;
  66. } // end namespace anki
  67. #endif