hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/platform/opengl/opengl_index_buffer.cpp
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2025-08-12 18:12:37 +0200
committerhachem <im@hachem.wtf>2025-08-12 18:12:37 +0200
commit50cdd344a3ed87c75a67739e2ffd34762e9b0895 (patch)
tree2a4a107e92687236c6676296281b89e14f8eac01 /src/platform/opengl/opengl_index_buffer.cpp
parentdbe642e5e26cf2bd99218f727157b58c7fed286e (diff)
feat: start of a basic rendering backend
Diffstat (limited to 'src/platform/opengl/opengl_index_buffer.cpp')
-rw-r--r--src/platform/opengl/opengl_index_buffer.cpp28
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..fac0585
--- /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)
+ {
+ glCreateBuffers(1, &m_renderer_id);
+ 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);
+ }
+
+ void OpenGLIndexBuffer::bind() const
+ {
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_renderer_id);
+ }
+
+ void OpenGLIndexBuffer::unbind() const
+ {
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ }
+};