CmApplication.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmCoreThreadAccessor.h"
  4. #include "CmHighLevelGpuProgram.h"
  5. #include "CmRenderWindow.h"
  6. #include "boost/signal.hpp"
  7. namespace BansheeEngine
  8. {
  9. class RenderWindow;
  10. class Viewport;
  11. class HighLevelGpuProgramManager;
  12. }
  13. namespace BansheeEngine
  14. {
  15. struct START_UP_DESC
  16. {
  17. String renderSystem;
  18. String renderer;
  19. String input;
  20. String sceneManager;
  21. RENDER_WINDOW_DESC primaryWindowDesc;
  22. Vector<String>::type importers;
  23. };
  24. class CM_EXPORT Application
  25. {
  26. public:
  27. Application();
  28. /**
  29. * @brief Starts the application using the specified options.
  30. * This is how you start the engine.
  31. */
  32. void startUp(START_UP_DESC& desc);
  33. /**
  34. * @brief Executes the main loop. This will cause actually rendering to be performed
  35. * and simulation to be run. Usually called immediately after startUp().
  36. *
  37. * This will run infinitely until stopMainLoop is called (usually from another thread or internally).
  38. */
  39. void runMainLoop();
  40. /**
  41. * @brief Stops a (infinite) main loop from running. The loop will complete its current cycle before stopping.
  42. * You may call this from other threads.
  43. */
  44. void stopMainLoop();
  45. /**
  46. * @brief Frees up all resources allocated during startUp, and while the application was running.
  47. */
  48. void shutDown();
  49. UINT64 getAppWindowId();
  50. RenderWindowPtr getPrimaryWindow() const { return mPrimaryWindow; }
  51. /**
  52. * @brief Loads a plugin.
  53. *
  54. * @param pluginName Name of the plugin to load, without extension.
  55. */
  56. void* loadPlugin(const String& pluginName, DynLib** library = nullptr);
  57. /**
  58. * @brief Unloads a plugin.
  59. */
  60. void unloadPlugin(DynLib* library);
  61. /**
  62. * @brief Called every frame by the main loop, after scene update and before rendering.
  63. */
  64. boost::signal<void()> mainLoopCallback;
  65. private:
  66. RenderWindowPtr mPrimaryWindow;
  67. DynLib* mSceneManagerPlugin;
  68. bool mIsFrameRenderingFinished;
  69. CM_MUTEX(mFrameRenderingFinishedMutex);
  70. CM_THREAD_SYNCHRONISER(mFrameRenderingFinishedCondition);
  71. volatile bool mRunMainLoop;
  72. /**
  73. * @brief Called when the frame finishes rendering.
  74. */
  75. void frameRenderingFinishedCallback();
  76. /**
  77. * @brief Called by the core thread to begin profiling.
  78. */
  79. void beginCoreProfiling();
  80. /**
  81. * @brief Called by the core thread to end profiling.
  82. */
  83. void endCoreProfiling();
  84. };
  85. CM_EXPORT Application& gApplication();
  86. }