From a2ec7dabd48a70ea69623406ddd0f8f97af403c8 Mon Sep 17 00:00:00 2001 From: hachem Date: Tue, 12 Aug 2025 18:12:37 +0200 Subject: [add]: Start of a basic rendering backend --- src/Rendering/Shader.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Rendering/Shader.h (limited to 'src/Rendering/Shader.h') diff --git a/src/Rendering/Shader.h b/src/Rendering/Shader.h new file mode 100644 index 0000000..a6b287a --- /dev/null +++ b/src/Rendering/Shader.h @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include +#include + +namespace Donut +{ + class Shader + { + public: + virtual ~Shader() = default; + + virtual void Bind() const = 0; + virtual void Unbind() const = 0; + + virtual void SetInt(const std::string& name, int value) = 0; + virtual void SetIntArray(const std::string& name, int* values, uint32_t count) = 0; + virtual void SetFloat(const std::string& name, float value) = 0; + virtual void SetFloat3(const std::string& name, const glm::vec3& value) = 0; + virtual void SetFloat4(const std::string& name, const glm::vec4& value) = 0; + virtual void SetMat4(const std::string& name, const glm::mat4& value) = 0; + + virtual const std::string& GetName() const = 0; + + static Shader* Create(const std::string& filepath); + static Shader* Create(const std::string& name, const std::string& vertexSrc, const std::string& fragmentSrc); + }; + + class ShaderLibrary + { + public: + void Add(const std::shared_ptr& shader); + void Add(const std::string& name, const std::shared_ptr& shader); + std::shared_ptr Load(const std::string& filepath); + std::shared_ptr Load(const std::string& name, const std::string& filepath); + + std::shared_ptr Get(const std::string& name); + + bool Exists(const std::string& name) const; + + private: + std::unordered_map> m_Shaders; + }; +}; -- cgit v1.3