#include "VertexBuffer.h"


VertexBuffer::VertexBuffer(const void * data, unsigned int size)
{
	GLCALL(glGenBuffers(1, &m_renderer_ID)); // Generate buffer space (number of buffers, get buffer index)
	GLCALL(glBindBuffer(GL_ARRAY_BUFFER, m_renderer_ID)); // Select target buffer object
	GLCALL(glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW)); // Save buffer data to GPU VRAM
}

VertexBuffer::~VertexBuffer()
{
	GLCALL(glDeleteBuffers(1, &m_renderer_ID)); // Delete buffer (how many buffers, what buffer)
}

void VertexBuffer::Bind() const
{
	GLCALL(glBindBuffer(GL_ARRAY_BUFFER, m_renderer_ID)); // Select target buffer object
}

void VertexBuffer::UnBind() const
{
	GLCALL(glBindBuffer(GL_ARRAY_BUFFER, 0)); // Unselect
}
