#include "IndexBuffer.hpp"

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

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

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

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