diff options
| author | hachem <im@hachem.wtf> | 2026-08-20 02:27:02 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-20 02:40:07 +0200 |
| commit | 5b361d81dbd2af0d0e99b9eb1adebea76ff05db0 (patch) | |
| tree | 34db1df17e8c7248aeeb92156d635d31c2484e3f /src/platform/opengl/opengl_texture.h | |
| parent | e3abaaf59777258ba06705135a0cafcb5918ad12 (diff) | |
[chore]: MASSIVE refactor + more vulkan bs
Diffstat (limited to 'src/platform/opengl/opengl_texture.h')
| -rw-r--r-- | src/platform/opengl/opengl_texture.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/platform/opengl/opengl_texture.h b/src/platform/opengl/opengl_texture.h new file mode 100644 index 0000000..7aa87ea --- /dev/null +++ b/src/platform/opengl/opengl_texture.h @@ -0,0 +1,68 @@ +#pragma once + +#include "rendering/texture.h" +#include "core/log.h" + +#include <glad/glad.h> + +namespace Donut +{ + class OpenGLTexture2D + : public Texture2D + { + public: + OpenGLTexture2D(uint32_t width, uint32_t height); + OpenGLTexture2D(const std::string& path); + virtual ~OpenGLTexture2D(); + + virtual auto get_width() const -> uint32_t override{ return m_width; } + virtual auto get_height() const -> uint32_t override{ return m_height; } + virtual auto get_renderer_id() const -> uint32_t override{ return m_renderer_id; } + + virtual auto set_data(void* data, uint32_t size) -> void override; + virtual auto bind(uint32_t slot = 0) const -> void override; + virtual auto bind_as_image(uint32_t slot = 0, bool read_only = false) const -> void override; + + virtual bool operator==(const Texture& other) const override + { + return m_renderer_id == other.get_renderer_id(); + } + + private: + std::string m_path; + uint32_t m_width, m_height; + uint32_t m_renderer_id; + GLenum m_internal_format, m_data_format; + }; + + class OpenGLCubemapTexture + : public CubemapTexture + { + public: + OpenGLCubemapTexture(uint32_t width, uint32_t height); + OpenGLCubemapTexture(const std::string& path); + virtual ~OpenGLCubemapTexture(); + + virtual auto get_width() const -> uint32_t override{ return m_width; } + virtual auto get_height() const -> uint32_t override{ return m_height; } + virtual auto get_renderer_id() const -> uint32_t override{ return m_renderer_id; } + + virtual auto set_data(void* data, uint32_t size) -> void override; + virtual auto bind(uint32_t slot = 0) const -> void override; + virtual auto bind_as_image(uint32_t slot = 0, bool read_only = false) const -> void override; + + virtual bool operator==(const Texture& other) const override + { + return m_renderer_id == other.get_renderer_id(); + } + + private: + void LoadHDRI(const std::string& path); + auto convert_equirectangular_to_cubemap(float* hdr_data, int width, int height) -> void; + + std::string m_path; + uint32_t m_width, m_height; + uint32_t m_renderer_id; + GLenum m_internal_format, m_data_format; + }; +} |
