| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsPrerequisites.h" |
| 6 | #include "BsCoreApplication.h" |
| 7 | #include "Utility/BsEvent.h" |
| 8 | |
| 9 | namespace bs |
| 10 | { |
| 11 | /** @addtogroup Application-Engine |
| 12 | * @{ |
| 13 | */ |
| 14 | |
| 15 | /** Primary entry point for the framework. Handles startup and shutdown. */ |
| 16 | class BS_EXPORT Application : public CoreApplication |
| 17 | { |
| 18 | private: |
| 19 | /** |
| 20 | * Builds the start-up descriptor structure, filling out the provided parameters and using the default values |
| 21 | * for the rest. |
| 22 | */ |
| 23 | static START_UP_DESC buildStartUpDesc(VideoMode videoMode, const String& title, bool fullscreen); |
| 24 | public: |
| 25 | Application(const START_UP_DESC& desc); |
| 26 | virtual ~Application(); |
| 27 | |
| 28 | /** Starts the framework. If using a custom Application system, provide it as a template parameter. */ |
| 29 | template<class T = Application> |
| 30 | static void startUp(VideoMode videoMode, const String& title, bool fullscreen) |
| 31 | { |
| 32 | START_UP_DESC desc = buildStartUpDesc(videoMode, title, fullscreen); |
| 33 | CoreApplication::startUp<T>(desc); |
| 34 | } |
| 35 | |
| 36 | /** Starts the framework. If using a custom Application system, provide it as a template parameter. */ |
| 37 | template<class T = Application> |
| 38 | static void startUp(const START_UP_DESC& desc) |
| 39 | { |
| 40 | CoreApplication::startUp<T>(desc); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Shows the profiler overlay. |
| 45 | * |
| 46 | * @param[in] type Type of information to display on the overlay. |
| 47 | * @param[in] camera Camera to show the overlay on. If none the overlay will be shown on the main camera. |
| 48 | */ |
| 49 | void showProfilerOverlay(ProfilerOverlayType type, const SPtr<Camera>& camera = nullptr); |
| 50 | |
| 51 | /** Hides the profiler overlay. */ |
| 52 | void hideProfilerOverlay(); |
| 53 | |
| 54 | protected: |
| 55 | /** @copydoc Module::onStartUp */ |
| 56 | void onStartUp() override; |
| 57 | |
| 58 | /** @copydoc Module::onShutDown */ |
| 59 | void onShutDown() override; |
| 60 | |
| 61 | /** @copydoc CoreApplication::preUpdate */ |
| 62 | void preUpdate() override; |
| 63 | |
| 64 | /** @copydoc CoreApplication::postUpdate */ |
| 65 | void postUpdate() override; |
| 66 | |
| 67 | /** @copydoc CoreApplication::startUpRenderer */ |
| 68 | void startUpRenderer() override; |
| 69 | |
| 70 | /** Initializes the script manager. */ |
| 71 | virtual void startUpScriptManager(); |
| 72 | |
| 73 | /** Calls per-frame update on the script manager. */ |
| 74 | virtual void updateScriptManager(); |
| 75 | |
| 76 | /** @copydoc CoreApplication::getShaderIncludeHandler */ |
| 77 | SPtr<IShaderIncludeHandler> getShaderIncludeHandler() const override; |
| 78 | |
| 79 | SPtr<ProfilerOverlay> mProfilerOverlay; |
| 80 | }; |
| 81 | |
| 82 | /** Easy way to access Application. */ |
| 83 | BS_EXPORT Application& gApplication(); |
| 84 | |
| 85 | /** @} */ |
| 86 | } |