CmApplication.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmHighLevelGpuProgram.h"
  4. namespace CamelotFramework
  5. {
  6. class RenderWindow;
  7. class Viewport;
  8. class HighLevelGpuProgramManager;
  9. }
  10. namespace CamelotFramework
  11. {
  12. struct START_UP_DESC
  13. {
  14. String renderSystem;
  15. String renderer;
  16. String input;
  17. String sceneManager;
  18. std::vector<String> importers;
  19. String resourceCacheDirectory;
  20. };
  21. class CM_EXPORT Application
  22. {
  23. public:
  24. Application();
  25. /**
  26. * @brief Starts the application using the specified options.
  27. * This is how you start the engine.
  28. */
  29. void startUp(const START_UP_DESC& desc);
  30. /**
  31. * @brief Executes the main loop. This will cause actually rendering to be performed
  32. * and simulation to be run. Usually called immediately after startUp().
  33. *
  34. * This will run infinitely until stopMainLoop is called (usually from another thread or internally).
  35. */
  36. void runMainLoop();
  37. /**
  38. * @brief Stops a (infinite) main loop from running. The loop will complete its current cycle before stopping.
  39. * You may call this from other threads.
  40. */
  41. void stopMainLoop();
  42. /**
  43. * @brief Frees up all resources allocated during startUp, and while the application was running.
  44. */
  45. void shutDown();
  46. UINT64 getAppWindowId();
  47. RenderWindowPtr getPrimaryRenderWindow() const { return mPrimaryRenderWindow; }
  48. // TODO: This is just for debug purposes. Normally I'd want to have one render context per scene view, not one global one
  49. DeferredRenderContextPtr getPrimaryRenderContext() const { return mPrimaryRenderContext; }
  50. /**
  51. * @brief Loads a plugin.
  52. *
  53. * @param pluginName Name of the plugin to load, without extension.
  54. */
  55. void* loadPlugin(const String& pluginName);
  56. private:
  57. RenderWindowPtr mPrimaryRenderWindow;
  58. DeferredRenderContextPtr mPrimaryRenderContext;
  59. bool mIsFrameRenderingFinished;
  60. CM_MUTEX(mFrameRenderingFinishedMutex);
  61. volatile bool mRunMainLoop;
  62. /**
  63. * @brief Runs the OS specific message pump.
  64. */
  65. void updateMessagePump();
  66. /**
  67. * @brief Called when the frame finishes rendering.
  68. */
  69. void frameRenderingFinishedCallback();
  70. };
  71. CM_EXPORT Application& gApplication();
  72. }