2
0

BsGLRenderAPIFactory.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include <string>
  5. #include "BsRenderAPIFactory.h"
  6. #include "BsRenderAPIManager.h"
  7. #include "BsGLRenderAPI.h"
  8. namespace bs { namespace ct
  9. {
  10. /** @addtogroup GL
  11. * @{
  12. */
  13. static const char* SystemName = "BansheeGLRenderSystem";
  14. /** Handles creation of the OpenGL render system. */
  15. class GLRenderAPIFactory : public RenderAPIFactory
  16. {
  17. public:
  18. /** @copydoc RenderAPIFactory::create */
  19. void create() override;
  20. /** @copydoc RenderAPIFactory::name */
  21. const char* name() const override { return SystemName; }
  22. private:
  23. /** Registers the factory with the render system manager when constructed. */
  24. class InitOnStart
  25. {
  26. public:
  27. InitOnStart()
  28. {
  29. static SPtr<RenderAPIFactory> newFactory;
  30. if(newFactory == nullptr)
  31. {
  32. newFactory = bs_shared_ptr_new<GLRenderAPIFactory>();
  33. RenderAPIManager::instance().registerFactory(newFactory);
  34. }
  35. }
  36. };
  37. static InitOnStart initOnStart; // Makes sure factory is registered on library load
  38. };
  39. /** @} */
  40. }}