2
0

CmApplication.h 2.1 KB

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