CmApplication.h 2.3 KB

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