From 9671d5e54484b8bce261207d08ff15053ae24e48 Mon Sep 17 00:00:00 2001 From: hachem Date: Thu, 14 Aug 2025 00:28:27 +0200 Subject: feat: ability to switch render API --- src/rendering/renderer.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/rendering/renderer.h') 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 #include namespace Donut { - template - using Scope = std::unique_ptr; - - template - constexpr Scope create_scope(Args&& ... args) - { - return std::make_unique(std::forward(args)...); - } - class RendererAPI { public: @@ -39,8 +31,9 @@ namespace Donut virtual void draw_indexed(const std::shared_ptr& vertex_array, uint32_t index_count = 0) = 0; - inline static API get_api() { return s_api; } - static Scope create(); + inline static API get_api() { return s_api; } + inline static void set_api(API api) { s_api = api; } + static std::unique_ptr create(); private: static API s_api; }; @@ -84,7 +77,7 @@ namespace Donut } private: - static Scope s_renderer_api; + static std::unique_ptr s_renderer_api; }; class Renderer -- cgit v1.3