text: #include "bmpch.h"
  #include "OpenGLBuffer.h"
  #include "OpenGLDebug.h"
  
  #include <glad/glad.h>
  
  namespace Basement {
  
  	//---------------------------------------------------------
  	//---Vertex Buffer-----------------------------------------
  	OpenGLVertexBuffer::OpenGLVertexBuffer(u32 size, float* vertices)
  	{
  		m_Count = size;
  
  		glGenBuffers(1, &m_VertexBufferID);
  		glBindBuffer(GL_ARRAY_BUFFER, m_VertexBufferID);
  		glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
  	}
  
  	OpenGLVertexBuffer::OpenGLVertexBuffer(const std::vector<Vertex>& vertices)
  	{
  		m_Count = static_cast<u32>(vertices.size() * sizeof(Vertex));
  
  		glGenBuffers(1, &m_VertexBufferID);
  		glBindBuffer(GL_ARRAY_BUFFER, m_VertexBufferID);
  		glBufferData(GL_ARRAY_BUFFER, m_Count, &vertices[0], GL_STATIC_DRAW);
  	}
  
  	OpenGLVertexBuffer::~OpenGLVertexBuffer()
  	{
  		glDeleteBuffers(1, &m_VertexBufferID);
  	}
  
  	void OpenGLVertexBuffer::Bind() const
  	{
  		glBindBuffer(GL_ARRAY_BUFFER, m_VertexBufferID);
  	}
  
  	void OpenGLVertexBuffer::Unbind() const
  	{
  		glBindBuffer(GL_ARRAY_BUFFER, 0);
  	}
  
  	//---------------------------------------------------------
  	//---Index Buffer-----------------------------------------
  	OpenGLIndexBuffer::OpenGLIndexBuffer(u32 count, u32* indices)
  	{
  		m_Count = count;
  
  		glGenBuffers(1, &m_IndexBufferID);
  		glBindBuffer(GL_ARRAY_BUFFER, m_IndexBufferID);
  		glBufferData(GL_ARRAY_BUFFER, count * sizeof(u32), indices, GL_STATIC_DRAW);
  	}
  
  	OpenGLIndexBuffer::OpenGLIndexBuffer(const std::vector<u32>& indices)
  	{
  		m_Count = static_cast<u32>(indices.size());
  
  		glGenBuffers(1, &m_IndexBufferID);
  		glBindBuffer(GL_ARRAY_BUFFER, m_IndexBufferID);
  		glBufferData(GL_ARRAY_BUFFER, m_Count * sizeof(u32), &indices[0], GL_STATIC_DRAW);
  
  		//GL_ELEMENT_ARRAY_BUFFER
  	}
  
  	OpenGLIndexBuffer::~OpenGLIndexBuffer()
  	{
  		glDeleteBuffers(1, &m_IndexBufferID);
  	}
  
  	void OpenGLIndexBuffer::Bind() const
  	{
  		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IndexBufferID);
  	}
  
  	void OpenGLIndexBuffer::Unbind() const
  	{
  		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
  	}
  
  	//---------------------------------------------------------
  	//---Uniform Buffer----------------------------------------
  
  	OpenGLUniformBuffer::OpenGLUniformBuffer()
  	{
  		glGenBuffers(1, &m_UniformBufferID);
  		glBindBuffer(GL_UNIFORM_BUFFER, m_UniformBufferID);
  	}
  
  	OpenGLUniformBuffer::~OpenGLUniformBuffer()
  	{
  		glDeleteBuffers(1, &m_UniformBufferID);
  	}
  
  	void OpenGLUniformBuffer::Bind() const
  	{
  		glBindBuffer(GL_UNIFORM_BUFFER, m_UniformBufferID);
  	}
  
  	void OpenGLUniformBuffer::Unbind() const
  	{
  		glBindBuffer(GL_UNIFORM_BUFFER, 0);
  	}
  
  }