BsGLRenderAPIFactory.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 BansheeEngine
  9. {
  10. const String SystemName = "BansheeGLRenderSystem";
  11. /**
  12. * @brief Handles creation of the OpenGL render system.
  13. */
  14. class GLRenderAPIFactory : public RenderAPIFactory
  15. {
  16. public:
  17. /**
  18. * @copydoc RenderSystemFactory::create
  19. */
  20. virtual void create();
  21. /**
  22. * @copydoc RenderSystemFactory::name
  23. */
  24. virtual const String& name() const { return SystemName; }
  25. private:
  26. /**
  27. * @brief Registers the factory with the render system manager when constructed.
  28. */
  29. class InitOnStart
  30. {
  31. public:
  32. InitOnStart()
  33. {
  34. static RenderAPIFactoryPtr newFactory;
  35. if(newFactory == nullptr)
  36. {
  37. newFactory = bs_shared_ptr_new<GLRenderAPIFactory>();
  38. RenderAPIManager::instance().registerFactory(newFactory);
  39. }
  40. }
  41. };
  42. static InitOnStart initOnStart; // Makes sure factory is registered on library load
  43. };
  44. }