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 <string> |
6 | #include "Managers/BsRenderAPIFactory.h" |
7 | #include "Managers/BsRenderAPIManager.h" |
8 | #include "BsGLRenderAPI.h" |
9 | |
10 | namespace bs { namespace ct |
11 | { |
12 | /** @addtogroup GL |
13 | * @{ |
14 | */ |
15 | /** Handles creation of the OpenGL render system. */ |
16 | class GLRenderAPIFactory : public RenderAPIFactory |
17 | { |
18 | public: |
19 | static constexpr const char* SystemName = "bsfGLRenderAPI" ; |
20 | |
21 | /** @copydoc RenderAPIFactory::create */ |
22 | void create() override; |
23 | |
24 | /** @copydoc RenderAPIFactory::name */ |
25 | const char* name() const override { return SystemName; } |
26 | |
27 | private: |
28 | /** Registers the factory with the render system manager when constructed. */ |
29 | class InitOnStart |
30 | { |
31 | public: |
32 | InitOnStart() |
33 | { |
34 | static SPtr<RenderAPIFactory> newFactory; |
35 | if(newFactory == nullptr) |
36 | { |
37 | newFactory = bs_shared_ptr_new<GLRenderAPIFactory>(); |
38 | RenderAPIManager::instance().registerFactory(newFactory); |
39 | } |
40 | } |
41 | }; |
42 | |
43 | static InitOnStart initOnStart; // Makes sure factory is registered on library load |
44 | }; |
45 | |
46 | /** @} */ |
47 | }} |
48 | |