From a2ec7dabd48a70ea69623406ddd0f8f97af403c8 Mon Sep 17 00:00:00 2001 From: hachem Date: Tue, 12 Aug 2025 18:12:37 +0200 Subject: [add]: Start of a basic rendering backend --- src/Platform/OpenGL/OpenGLIndexBuffer.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Platform/OpenGL/OpenGLIndexBuffer.cpp (limited to 'src/Platform/OpenGL/OpenGLIndexBuffer.cpp') diff --git a/src/Platform/OpenGL/OpenGLIndexBuffer.cpp b/src/Platform/OpenGL/OpenGLIndexBuffer.cpp new file mode 100644 index 0000000..7faee62 --- /dev/null +++ b/src/Platform/OpenGL/OpenGLIndexBuffer.cpp @@ -0,0 +1,28 @@ +#include "OpenGLIndexBuffer.h" +#include + +namespace Donut +{ + OpenGLIndexBuffer::OpenGLIndexBuffer(const uint32_t* indices, uint32_t count) + : m_Count(count) + { + glCreateBuffers(1, &m_RendererID); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(uint32_t), indices, GL_STATIC_DRAW); + } + + OpenGLIndexBuffer::~OpenGLIndexBuffer() + { + glDeleteBuffers(1, &m_RendererID); + } + + void OpenGLIndexBuffer::Bind() const + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID); + } + + void OpenGLIndexBuffer::Unbind() const + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } +}; -- cgit v1.3