App.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef APP_H
  2. #define APP_H
  3. #include <SDL/SDL.h>
  4. #include <boost/filesystem.hpp>
  5. #include "StdTypes.h"
  6. #include "Properties.h"
  7. #include "Exception.h"
  8. #include "Singleton.h"
  9. class StdinListener;
  10. class Scene;
  11. class Camera;
  12. class Input;
  13. /// This class holds all the global objects of the application and its also responsible for some of the SDL stuff.
  14. /// It should be singleton
  15. class App
  16. {
  17. PROPERTY_R(uint, windowW, getWindowWidth) ///< The main window width
  18. PROPERTY_R(uint, windowH, getWindowHeight) ///< The main window height
  19. PROPERTY_R(boost::filesystem::path, settingsPath, getSettingsPath)
  20. PROPERTY_R(boost::filesystem::path, cachePath, getCachePath)
  21. public:
  22. uint timerTick;
  23. App() {}
  24. ~App() {}
  25. void init(int argc, char* argv[]);
  26. void quit(int code);
  27. void waitForNextFrame();
  28. void togleFullScreen();
  29. void swapBuffers();
  30. /// The func pools the stdinListener for string in the console, if there are any it executes them with
  31. /// scriptingEngine
  32. void execStdinScpripts();
  33. static void printAppInfo();
  34. uint getDesktopWidth() const;
  35. uint getDesktopHeight() const;
  36. /// @name Accessors
  37. /// @{
  38. bool isTerminalColoringEnabled() const;
  39. Camera* getActiveCam() {return activeCam;}
  40. void setActiveCam(Camera* cam) {activeCam = cam;}
  41. /// @}
  42. /// @return Returns the number of milliseconds since SDL library initialization
  43. static uint getTicks();
  44. private:
  45. bool terminalColoringEnabled; ///< Terminal coloring for Unix terminals. Default on
  46. uint time;
  47. SDL_WindowID windowId;
  48. SDL_GLContext glContext;
  49. SDL_Surface* iconImage;
  50. bool fullScreenFlag;
  51. Camera* activeCam; ///< Pointer to the current camera
  52. void parseCommandLineArgs(int argc, char* argv[]);
  53. /// A slot to handle the messageHandler's signal
  54. void handleMessageHanlderMsgs(const char* file, int line, const char* func, const char* msg);
  55. void initWindow();
  56. void initDirs();
  57. void initRenderer();
  58. };
  59. inline bool App::isTerminalColoringEnabled() const
  60. {
  61. return terminalColoringEnabled;
  62. }
  63. typedef Singleton<App> AppSingleton;
  64. #endif