diff options
| author | hachem <im@hachem.wtf> | 2025-08-14 00:28:27 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2025-08-14 00:28:27 +0200 |
| commit | 9671d5e54484b8bce261207d08ff15053ae24e48 (patch) | |
| tree | 0bd7018fd818eb16069f27102b9e489d5369bcf6 /src/rendering/renderer.h | |
| parent | 0262eeea8762cdeb14c98d22473ebf0fd6b37bf9 (diff) | |
feat: ability to switch render API
Diffstat (limited to 'src/rendering/renderer.h')
| -rw-r--r-- | src/rendering/renderer.h | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/rendering/renderer.h b/src/rendering/renderer.h index c7ace3c..dd4c259 100644 --- a/src/rendering/renderer.h +++ b/src/rendering/renderer.h @@ -2,20 +2,12 @@ #include "vertex_array.h" #include "shader.h" + #include <glm/glm.hpp> #include <memory> namespace Donut { - template<typename T> - using Scope = std::unique_ptr<T>; - - template<typename T, typename ... Args> - constexpr Scope<T> create_scope(Args&& ... args) - { - return std::make_unique<T>(std::forward<Args>(args)...); - } - class RendererAPI { public: @@ -39,8 +31,9 @@ namespace Donut virtual void draw_indexed(const std::shared_ptr<VertexArray>& vertex_array, uint32_t index_count = 0) = 0; - inline static API get_api() { return s_api; } - static Scope<RendererAPI> create(); + inline static API get_api() { return s_api; } + inline static void set_api(API api) { s_api = api; } + static std::unique_ptr<RendererAPI> create(); private: static API s_api; }; @@ -84,7 +77,7 @@ namespace Donut } private: - static Scope<RendererAPI> s_renderer_api; + static std::unique_ptr<RendererAPI> s_renderer_api; }; class Renderer |
