aboutsummaryrefslogtreecommitdiff
path: root/src/rendering/vertex_buffer.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-23 17:21:37 +0200
committerhachem <im@hachem.wtf>2026-08-23 17:21:37 +0200
commit3fd33ecff7472e4d6fc9e6b3905f56982e497ef2 (patch)
tree66e5812f1a18b926e88a0dd549fe14e7c7327165 /src/rendering/vertex_buffer.h
parente3aa33fc9a99d8b817bda42a567a4c347e18ab32 (diff)
[feat]: complete RHI api
Diffstat (limited to 'src/rendering/vertex_buffer.h')
-rw-r--r--src/rendering/vertex_buffer.h78
1 files changed, 0 insertions, 78 deletions
diff --git a/src/rendering/vertex_buffer.h b/src/rendering/vertex_buffer.h
deleted file mode 100644
index 4e61700..0000000
--- a/src/rendering/vertex_buffer.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include <vector>
-
-namespace Donut
-{
- struct VertexBufferElement
- {
- uint32_t type;
- uint32_t count;
- uint8_t normalized;
- uint32_t offset;
-
- static auto get_size_of_type(uint32_t type) -> uint32_t;
- };
-
- class VertexBufferLayout
- {
- public:
- VertexBufferLayout() = default;
- ~VertexBufferLayout() = default;
-
- template<typename T>
- auto push(uint32_t count) -> void
- {
- static_assert(false);
- }
-
- template<>
- void push<float>(uint32_t count)
- {
- m_elements.push_back({ 0x1406, count, 0, m_stride }); // GL_FLOAT
- m_stride += count * VertexBufferElement::get_size_of_type(0x1406);
- }
-
- template<>
- void push<uint32_t>(uint32_t count)
- {
- m_elements.push_back({ 0x1405, count, 0, m_stride }); // GL_UNSIGNED_INT
- m_stride += count * VertexBufferElement::get_size_of_type(0x1405);
- }
-
- template<>
- void push<uint8_t>(uint32_t count)
- {
- m_elements.push_back({ 0x1401, count, 1, m_stride }); // GL_UNSIGNED_BYTE
- m_stride += count * VertexBufferElement::get_size_of_type(0x1401);
- }
-
- inline auto get_elements() const -> const std::vector<VertexBufferElement>& { return m_elements; }
- inline auto get_stride() const -> uint32_t { return m_stride; }
-
- private:
- std::vector<VertexBufferElement> m_elements;
- uint32_t m_stride = 0;
- };
-
- class VertexBuffer
- {
- public:
- VertexBuffer(const void* data, uint32_t size);
- ~VertexBuffer();
-
- auto bind() const -> void;
- auto unbind() const -> void;
- auto set_data(const void* data, uint32_t size) -> void;
-
- auto get_layout() const -> const VertexBufferLayout& { return m_layout; }
- auto set_layout(const VertexBufferLayout& layout) -> void { m_layout = layout; }
-
- static auto create(const void* data, uint32_t size) -> VertexBuffer*;
-
- private:
- uint32_t m_renderer_id = 0;
- VertexBufferLayout m_layout;
- };
-};