BsGLRenderAPIFactory.h 999 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include <string>
  3. #include "BsRenderAPIFactory.h"
  4. #include "BsRenderAPIManager.h"
  5. #include "BsGLRenderAPI.h"
  6. namespace BansheeEngine
  7. {
  8. const String SystemName = "BansheeGLRenderSystem";
  9. /**
  10. * @brief Handles creation of the OpenGL render system.
  11. */
  12. class GLRenderAPIFactory : public RenderAPIFactory
  13. {
  14. public:
  15. /**
  16. * @copydoc RenderSystemFactory::create
  17. */
  18. virtual void create();
  19. /**
  20. * @copydoc RenderSystemFactory::name
  21. */
  22. virtual const String& name() const { return SystemName; }
  23. private:
  24. /**
  25. * @brief Registers the factory with the render system manager when constructed.
  26. */
  27. class InitOnStart
  28. {
  29. public:
  30. InitOnStart()
  31. {
  32. static RenderAPIFactoryPtr newFactory;
  33. if(newFactory == nullptr)
  34. {
  35. newFactory = bs_shared_ptr_new<GLRenderAPIFactory>();
  36. RenderAPIManager::instance().registerFactory(newFactory);
  37. }
  38. }
  39. };
  40. static InitOnStart initOnStart; // Makes sure factory is registered on library load
  41. };
  42. }