BsD3D11RenderAPIFactory.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 "BsD3D11RenderAPI.h"
  8. namespace BansheeEngine
  9. {
  10. const String SystemName = "BansheeD3D11RenderSystem";
  11. /**
  12. * @brief Handles creation of the DX11 render system.
  13. */
  14. class D3D11RenderAPIFactory : 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<D3D11RenderAPIFactory>();
  38. RenderAPIManager::instance().registerFactory(newFactory);
  39. }
  40. }
  41. };
  42. static InitOnStart initOnStart; // Makes sure factory is registered on program start
  43. };
  44. }