BsD3D9RenderAPIFactory.h 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <string>
  3. #include "BsRenderAPIFactory.h"
  4. #include "BsRenderAPIManager.h"
  5. #include "BsD3D9RenderAPI.h"
  6. namespace BansheeEngine
  7. {
  8. const String SystemName = "BansheeD3D9RenderSystem";
  9. /**
  10. * @brief Handles creation of the DX9 render system.
  11. */
  12. class D3D9RenderAPIFactory : 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<D3D9RenderAPIFactory>();
  36. RenderAPIManager::instance().registerFactory(newFactory);
  37. }
  38. }
  39. };
  40. static InitOnStart initOnStart; // Makes sure factory is registered on program start
  41. };
  42. }