PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/SpaceWings/include/Phoenix/Root.hpp

https://github.com/lesnip3r/ICT207-Project
C++ Header | 124 lines | 45 code | 26 blank | 53 comment | 0 complexity | c64afbe9336b13c19f54165acc484e5c MD5 | raw file
  1. /*
  2. * Root.hpp
  3. *
  4. * The root class object
  5. *
  6. * Created by Julien Lebot on 23/09/09.
  7. * Copyright 2009 Julien Lebot. All rights reserved.
  8. *
  9. */
  10. #ifndef __Root_hpp__
  11. #define __Root_hpp__
  12. #include <Phoenix/Base.h>
  13. #include <Phoenix/Window.hpp>
  14. #include <Phoenix/Singleton.hpp>
  15. #include <Phoenix/CPUInfo.hpp>
  16. #include <Phoenix/LogManager.hpp>
  17. namespace Phoenix
  18. {
  19. /**
  20. * @brief The root class object is the entry point to the rendering system.
  21. */
  22. class _PhoenixExport Root
  23. : public Singleton<Root>
  24. {
  25. // Needed for the singleton to be created since the ctor/dtor are private (it's a concrete class after all).
  26. friend struct CreateUsingNew<Root>;
  27. public:
  28. /// Initialise the system, it does important setup and must be called before everything else.
  29. bool initialize(const std::string& logFile = "Phoenix.log",
  30. const std::string& cfgFile = "Phoenix.cfg");
  31. /**
  32. * @brief Adds a new window to the render system, that window can subsequently be used for rendering.
  33. * The window does not have to be initialized when it's given to the rendering system but it must exist (as in allocated).
  34. * This allows the client to derive their class from the Window class and customize it.
  35. * Note that a strong reference will be kept by the system so you should not have to care about destroying the window yourself.
  36. *
  37. * @param window A pointer to the window to be added.
  38. * @Param autoConfigure Whether or not to let the system auto configure the window. Default (true) is recommended.
  39. */
  40. void addWindow(WindowPtr window,
  41. bool autoConfigure = true);
  42. /**
  43. * @brief Shuts down the system. You do not have to call this directly unless you must (e.g. if you need to shutdown the system prematurely as a
  44. * result of an error for example).
  45. */
  46. void shutdown();
  47. /**
  48. * @brief Enters main event processing loop. After this call (which does NOT return), events will be dispatched to the appropriate windows.
  49. */
  50. void enterMainLoop();
  51. /// Returns whether the system is initialized and ready to be used.
  52. bool isInitialised();
  53. /**
  54. * @brief Sets whether the idle event will be dispatched. Not all clients need the idle event, since they can have a time to replace it.
  55. *
  56. * @param enabled Whether to enable or disable the idle event.
  57. */
  58. void setIdle(bool enabled);
  59. /// In case the idle event dispatching is enabled, tells the system that the current active window will handle the idle events from now on.
  60. void setIdle2ActiveWindow(void);
  61. /// Get a reference to the log manager. This is a convenience method
  62. LogManager& getLogManager() { return LogManager::instance(); }
  63. private:
  64. /// Private default constructor
  65. Root();
  66. /// Private destructor
  67. ~Root();
  68. /// GLUT display callback
  69. static void CallBackDisplayFunc(void);
  70. /// GLUT idle callback
  71. static void CallBackIdleFunc(void);
  72. /// GLUT keyboard callback
  73. static void CallBackKeyboardUpFunc(unsigned char key, int x, int y);
  74. static void CallBackKeyboardFunc(unsigned char key, int x, int y);
  75. /// GLUT motion callback
  76. static void CallBackMotionFunc(int x, int y);
  77. /// GLUT mouse callback
  78. static void CallBackMouseFunc(int button, int state, int x, int y);
  79. /// GLUT passive motion callback
  80. static void CallBackPassiveMotionFunc(int x, int y);
  81. /// GLUT reshape callback
  82. static void CallBackReshapeFunc(int w, int h);
  83. /// GLUT special func callback
  84. static void CallBackSpecialUpFunc(int key, int x, int y);
  85. static void CallBackSpecialFunc(int key, int x, int y);
  86. /// GLUT visibility func callback
  87. static void CallBackVisibilityFunc(int visible);
  88. /// The handle of the window that is handling idle events
  89. static int mCurrentIdleWindow;
  90. /// Whether or not the idle event is enabled
  91. static bool mIdleFuncEnabled;
  92. /// Whether or not the initialization has been done
  93. bool mInitDone;
  94. /// Information about the CPU
  95. CPUInfo mCPUInfo;
  96. };
  97. }
  98. #endif // __Root_hpp__