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_index_buffer.cpp | |
| parent | e3abaaf59777258ba06705135a0cafcb5918ad12 (diff) | |
[chore]: MASSIVE refactor + more vulkan bs
Diffstat (limited to 'src/platform/opengl/opengl_index_buffer.cpp')
| -rw-r--r-- | src/platform/opengl/opengl_index_buffer.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/platform/opengl/opengl_index_buffer.cpp b/src/platform/opengl/opengl_index_buffer.cpp new file mode 100644 index 0000000..faa6b81 --- /dev/null +++ b/src/platform/opengl/opengl_index_buffer.cpp @@ -0,0 +1,28 @@ +#include "opengl_index_buffer.h" +#include <glad/glad.h> + +namespace Donut +{ + OpenGLIndexBuffer::OpenGLIndexBuffer(const uint32_t* indices, uint32_t count) + : m_count(count) + { + glGenBuffers(1, &m_renderer_id); // glCreateBuffers is 4.5 DSA; unavailable on macOS 4.1 + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_renderer_id); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(uint32_t), indices, GL_STATIC_DRAW); + } + + OpenGLIndexBuffer::~OpenGLIndexBuffer() + { + glDeleteBuffers(1, &m_renderer_id); + } + + auto OpenGLIndexBuffer::bind() const -> void + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_renderer_id); + } + + auto OpenGLIndexBuffer::unbind() const -> void + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } +}; |
