text: #include "pch.h"
  #include "OpenGLIndexBuffer.h"
  
  #include <glad/glad.h>
  
  namespace BrickEngine {
  
  	OpenGLIndexBuffer::OpenGLIndexBuffer(uint32_t* data, uint32_t count)
  		: m_Count(count), m_Type(GL_STATIC_DRAW)
  	{
  		glGenBuffers(1, &m_RendererID);
  		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID);
  		glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(uint32_t), data, m_Type);
  	}
  
  	OpenGLIndexBuffer::OpenGLIndexBuffer(uint32_t count)
  		: m_Count(count), m_Type(GL_DYNAMIC_DRAW)
  	{
  		glGenBuffers(1, &m_RendererID);
  		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID);
  		glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(uint32_t), nullptr, m_Type);
  	}
  
  	OpenGLIndexBuffer::~OpenGLIndexBuffer()
  	{
  		glDeleteBuffers(1, &m_RendererID);
  	}
  
  	void OpenGLIndexBuffer::SetData(uint32_t* data, uint32_t count)
  	{
  		m_Count = count;
  		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID);
  		glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(uint32_t), data, m_Type);
  	}
  
  	void OpenGLIndexBuffer::Bind()
  	{
  		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID);
  	}
  
  	void OpenGLIndexBuffer::UnBind()
  	{
  		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
  	}
  
  }
  