QGearsApplication.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. -----------------------------------------------------------------------------
  3. Copyright (c) 19.10.2013 Tobias Peters <tobias.peters@kreativeffekt.at>
  4. This file is part of Q-Gears
  5. Q-Gears is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, version 2.0 (GPLv2) of the License.
  8. Q-Gears is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. -----------------------------------------------------------------------------
  13. */
  14. #ifndef __QGearsApplication_H__
  15. #define __QGearsApplication_H__
  16. #include <OgreRoot.h>
  17. #include <OgreOverlaySystem.h>
  18. #include <memory>
  19. #include "TypeDefine.h"
  20. namespace QGears
  21. {
  22. class Application : public Ogre::Singleton<Application>
  23. {
  24. public:
  25. Application(Ogre::String pluginsFileName, Ogre::String resourcesFile, Ogre::String logFileName)
  26. : m_plugins_filename(pluginsFileName), m_resources_filename(resourcesFile), m_log_filename(logFileName)
  27. {
  28. }
  29. Application( int argc, char *argv[] );
  30. virtual ~Application();
  31. bool initOgre( bool hideWindow = false );
  32. Ogre::Root* getRoot( void );
  33. Ogre::RenderWindow* getRenderWindow( void );
  34. const String& getResourcesFilename( void );
  35. Ogre::ResourceGroupManager* ResMgr() { return mResMgr; }
  36. protected:
  37. String getWindowTitle( void ) const;
  38. bool processCommandLine( int argc, char *argv[] );
  39. void registerArchiveFactories( void );
  40. void loadResourcesConfig( void );
  41. void initComponents( void );
  42. void destroyComponents( void );
  43. void createResourceManagers( void );
  44. void destroyResourceManagers( void );
  45. private:
  46. typedef std::vector<std::shared_ptr<Ogre::ResourceManager>> ResourceManagerVector;
  47. static const char* CLI_SECTION_GENERIC;
  48. static const char* CLI_HELP;
  49. static const char* CLI_HELP_DESCRIPTION;
  50. static const char* CLI_CONFIG_FILE;
  51. static const char* CLI_CONFIG_FILE_DESCRIPTION;
  52. static const char* CLI_LOG_FILE;
  53. static const char* CLI_LOG_FILE_DESCRIPTION;
  54. static const char* CLI_PLUGINS_FILE;
  55. static const char* CLI_PLUGINS_FILE_DESCRIPTION;
  56. static const char* CLI_RESOURCES_FILE;
  57. static const char* CLI_RESOURCES_FILE_DESCRIPTION;
  58. int m_argc = 0;
  59. char **m_argv = nullptr;
  60. String m_config_filename;
  61. String m_log_filename;
  62. String m_plugins_filename;
  63. String m_resources_filename;
  64. bool m_initialized = false;
  65. std::unique_ptr<Ogre::Root> m_root;
  66. std::unique_ptr<Ogre::OverlaySystem> m_overlay_system;
  67. Ogre::RenderWindow* m_render_window = nullptr; // Not owned
  68. ResourceManagerVector m_resource_managers;
  69. Ogre::ResourceGroupManager* mResMgr = nullptr; // Not owned
  70. };
  71. }
  72. #endif // __QGearsApplication_H__