BsVulkanRenderAPIFactory.h 1.2 KB

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