#include "IndexBuffer.hpp"

TSE::GLFW::IndexBuffer::IndexBuffer(ushort *data, ushort count)
{
    glGenBuffers(1, &bufferID);
    WriteData(data, count);
}

void TSE::GLFW::IndexBuffer::WriteData(ushort *data, ushort count)
{
    Bind();
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(ushort) * count, data, GL_DYNAMIC_DRAW);
    Unbind();
}

void TSE::GLFW::IndexBuffer::Bind()
{
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferID);
}

void TSE::GLFW::IndexBuffer::Unbind()
{
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
