App.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _APP_H_
  2. #define _APP_H_
  3. #include <SDL/SDL.h>
  4. #include "Common.h"
  5. /**
  6. * @brief This class contains all the global objects of the application. Its also responsible for some of the SDL stuff.
  7. * It should be singleton
  8. */
  9. class App
  10. {
  11. PROPERTY_R( uint, desktopW, getDesktopW ) ///< Property: The desktop width at App initialization
  12. PROPERTY_R( uint, desktopH, getDesktopH ) ///< Property: The desktop height at App initialization
  13. PROPERTY_RW( class Scene*, scene, setScene, getScene ) ///< Property: Pointer to the current scene
  14. PROPERTY_RW( class Camera*, activeCam, setActiveCam, getActiveCam ) ///< Property: Pointer to the current camera
  15. private:
  16. static bool isCreated; ///< A flag to ensure one @ref App instance
  17. uint time;
  18. SDL_Surface* mainSurf;
  19. SDL_Surface* iconImage;
  20. public:
  21. uint timerTick;
  22. uint windowW;
  23. uint windowH;
  24. App();
  25. ~App() {}
  26. void initWindow();
  27. void quitApp( int code );
  28. void waitForNextFrame();
  29. void togleFullScreen();
  30. static void printAppInfo();
  31. /**
  32. * @return Returns the number of milliseconds since SDL library initialization
  33. */
  34. static uint getTicks() { return SDL_GetTicks(); }
  35. };
  36. #endif