diff options
| author | hachem <im@hachem.wtf> | 2025-08-12 19:17:50 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2025-08-12 19:17:50 +0200 |
| commit | 1ad6bc34323f5b30d463ebe47a58d47ff9d4f328 (patch) | |
| tree | 535774e6db8e03fdb204c27734ca9fa43ab30a61 /src/Rendering | |
| parent | 8cf6858a6cd958f31521c4ce680cf2011bfb7cc3 (diff) | |
[add]: Texture and Pixel buffers
Diffstat (limited to 'src/Rendering')
| -rw-r--r-- | src/Rendering/Renderer.h | 6 | ||||
| -rw-r--r-- | src/Rendering/Texture.cpp | 32 | ||||
| -rw-r--r-- | src/Rendering/Texture.h | 30 |
3 files changed, 68 insertions, 0 deletions
diff --git a/src/Rendering/Renderer.h b/src/Rendering/Renderer.h index d08d015..82c156e 100644 --- a/src/Rendering/Renderer.h +++ b/src/Rendering/Renderer.h @@ -34,6 +34,7 @@ namespace Donut virtual void SetClearColor(const glm::vec4& color) = 0; virtual void Clear() = 0; virtual void EnableDepthTest() = 0; + virtual void SetFaceCulling(bool enabled) = 0; virtual void DrawIndexed(const std::shared_ptr<VertexArray>& vertexArray, uint32_t indexCount = 0) = 0; @@ -72,6 +73,11 @@ namespace Donut s_RendererAPI->EnableDepthTest(); } + inline static void SetFaceCulling(bool enabled) + { + s_RendererAPI->SetFaceCulling(enabled); + } + inline static void DrawIndexed(const std::shared_ptr<VertexArray>& vertexArray, uint32_t indexCount = 0) { s_RendererAPI->DrawIndexed(vertexArray, indexCount); diff --git a/src/Rendering/Texture.cpp b/src/Rendering/Texture.cpp new file mode 100644 index 0000000..a52a469 --- /dev/null +++ b/src/Rendering/Texture.cpp @@ -0,0 +1,32 @@ +#include "Texture.h" +#include "Renderer.h" +#include "../Platform/OpenGL/OpenGLTexture.h" + +namespace Donut +{ + std::shared_ptr<Texture2D> Texture2D::Create(uint32_t width, uint32_t height) + { + switch (Renderer::GetAPI()) + { + case RendererAPI::API::OpenGL: + return std::make_shared<OpenGLTexture2D>(width, height); + case RendererAPI::API::None: + return nullptr; + default: + return nullptr; + } + } + + std::shared_ptr<Texture2D> Texture2D::Create(const std::string& path) + { + switch (Renderer::GetAPI()) + { + case RendererAPI::API::OpenGL: + return std::make_shared<OpenGLTexture2D>(path); + case RendererAPI::API::None: + return nullptr; + default: + return nullptr; + } + } +};
\ No newline at end of file diff --git a/src/Rendering/Texture.h b/src/Rendering/Texture.h new file mode 100644 index 0000000..eebce85 --- /dev/null +++ b/src/Rendering/Texture.h @@ -0,0 +1,30 @@ +#pragma once + +#include <memory> +#include <string> +#include <glm/glm.hpp> + +namespace Donut +{ + class Texture + { + public: + virtual ~Texture() = default; + + virtual uint32_t GetWidth() const = 0; + virtual uint32_t GetHeight() const = 0; + virtual uint32_t GetRendererID() const = 0; + + virtual void SetData(void* data, uint32_t size) = 0; + virtual void Bind(uint32_t slot = 0) const = 0; + + virtual bool operator==(const Texture& other) const = 0; + }; + + class Texture2D : public Texture + { + public: + static std::shared_ptr<Texture2D> Create(uint32_t width, uint32_t height); + static std::shared_ptr<Texture2D> Create(const std::string& path); + }; +};
\ No newline at end of file |
