From 2c8002d30f291cba832a5750212009d48238c308 Mon Sep 17 00:00:00 2001 From: hachem Date: Fri, 22 Aug 2025 12:24:05 +0200 Subject: feat: add HDRI --- src/rendering/shader.h | 1 + src/rendering/texture.cpp | 30 ++++++++++++++++++++++++++++++ src/rendering/texture.h | 8 ++++++++ 3 files changed, 39 insertions(+) (limited to 'src/rendering') diff --git a/src/rendering/shader.h b/src/rendering/shader.h index 814f0cf..3e05132 100644 --- a/src/rendering/shader.h +++ b/src/rendering/shader.h @@ -34,6 +34,7 @@ namespace Donut virtual void memory_barrier(uint32_t barriers) = 0; virtual const std::string& get_name() const = 0; + virtual uint32_t get_renderer_id() const = 0; static Shader* create(const std::string& filepath); static Shader* create(const std::string& name, const std::string& vertex_src, const std::string& fragment_src); diff --git a/src/rendering/texture.cpp b/src/rendering/texture.cpp index e14c09c..a33edd0 100644 --- a/src/rendering/texture.cpp +++ b/src/rendering/texture.cpp @@ -35,4 +35,34 @@ namespace Donut return nullptr; } } + + Ref CubemapTexture::create(uint32_t width, uint32_t height) + { + switch (Renderer::get_api()) + { + case RendererAPI::API::OpenGL: + return create_ref(width, height); + case RendererAPI::API::Vulkan: + return create_ref(width, height); + case RendererAPI::API::None: + return nullptr; + default: + return nullptr; + } + } + + Ref CubemapTexture::create_from_hdri(const std::string& path) + { + switch (Renderer::get_api()) + { + case RendererAPI::API::OpenGL: + return create_ref(path); + case RendererAPI::API::Vulkan: + return create_ref(path); + case RendererAPI::API::None: + return nullptr; + default: + return nullptr; + } + } }; diff --git a/src/rendering/texture.h b/src/rendering/texture.h index cc5c59e..195605c 100644 --- a/src/rendering/texture.h +++ b/src/rendering/texture.h @@ -31,4 +31,12 @@ namespace Donut static Ref create(uint32_t width, uint32_t height); static Ref create(const std::string& path); }; + + class CubemapTexture + : public Texture + { + public: + static Ref create(uint32_t width, uint32_t height); + static Ref create_from_hdri(const std::string& path); + }; }; -- cgit v1.3