hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/rendering/shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rendering/shader.h')
-rw-r--r--src/rendering/shader.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/rendering/shader.h b/src/rendering/shader.h
new file mode 100644
index 0000000..d9128f6
--- /dev/null
+++ b/src/rendering/shader.h
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <memory>
+#include <glm/glm.hpp>
+
+namespace Donut
+{
+ class Shader
+ {
+ public:
+ virtual ~Shader() = default;
+
+ virtual void bind() const = 0;
+ virtual void unbind() const = 0;
+
+ virtual void set_int(const std::string& name, int value) = 0;
+ virtual void set_int_array(const std::string& name, int* values, uint32_t count) = 0;
+ virtual void set_float(const std::string& name, float value) = 0;
+ virtual void set_float3(const std::string& name, const glm::vec3& value) = 0;
+ virtual void set_float4(const std::string& name, const glm::vec4& value) = 0;
+ virtual void set_mat4(const std::string& name, const glm::mat4& value) = 0;
+
+ virtual const std::string& get_name() 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);
+ };
+
+ class ShaderLibrary
+ {
+ public:
+ void add(const std::shared_ptr<Shader>& shader);
+ void add(const std::string& name, const std::shared_ptr<Shader>& shader);
+ std::shared_ptr<Shader> load(const std::string& filepath);
+ std::shared_ptr<Shader> load(const std::string& name, const std::string& filepath);
+
+ std::shared_ptr<Shader> get(const std::string& name);
+
+ bool exists(const std::string& name) const;
+
+ private:
+ std::unordered_map<std::string, std::shared_ptr<Shader>> m_shaders;
+ };
+};