aboutsummaryrefslogtreecommitdiff
path: root/src/rendering/vertex_array.cpp
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_array.cpp
parente3aa33fc9a99d8b817bda42a567a4c347e18ab32 (diff)
[feat]: complete RHI api
Diffstat (limited to 'src/rendering/vertex_array.cpp')
-rw-r--r--src/rendering/vertex_array.cpp61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/rendering/vertex_array.cpp b/src/rendering/vertex_array.cpp
deleted file mode 100644
index cddcf35..0000000
--- a/src/rendering/vertex_array.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <glad/glad.h>
-
-#include "vertex_array.h"
-
-namespace Donut
-{
- VertexArray::VertexArray()
- {
- // glCreateVertexArrays is 4.5 DSA; macOS caps at 4.1. glGenVertexArrays
- // reserves the name and the VAO is created on first bind (done below).
- glGenVertexArrays(1, &m_renderer_id);
- }
-
- VertexArray::~VertexArray()
- {
- glDeleteVertexArrays(1, &m_renderer_id);
- }
-
- auto VertexArray::bind() const -> void
- {
- glBindVertexArray(m_renderer_id);
- }
-
- auto VertexArray::unbind() const -> void
- {
- glBindVertexArray(0);
- }
-
- auto VertexArray::add_vertex_buffer(const Ref<VertexBuffer>& vertex_buffer) -> void
- {
- glBindVertexArray(m_renderer_id);
- vertex_buffer->bind();
-
- const auto& layout = vertex_buffer->get_layout();
- for (const auto& element : layout.get_elements())
- {
- glEnableVertexAttribArray(m_vertex_buffer_index);
- glVertexAttribPointer(m_vertex_buffer_index,
- element.count,
- element.type,
- element.normalized ? GL_TRUE : GL_FALSE,
- layout.get_stride(),
- reinterpret_cast<const void*>(static_cast<uintptr_t>(element.offset)));
- m_vertex_buffer_index++;
- }
-
- m_vertex_buffers.push_back(vertex_buffer);
- }
-
- auto VertexArray::set_index_buffer(const Ref<IndexBuffer>& index_buffer) -> void
- {
- glBindVertexArray(m_renderer_id);
- index_buffer->bind();
- m_index_buffer = index_buffer;
- }
-
- auto VertexArray::create() -> VertexArray*
- {
- return new VertexArray();
- }
-};