#include <gearlib.h>

UniformBuffer* create_uniform_buffer(size_t size) {
    UniformBuffer* buffer = calloc(sizeof(UniformBuffer), 1);
    buffer->size = size;

    glCreateBuffers(1, &buffer->ubo);
    glNamedBufferStorage(buffer->ubo, buffer->size, NULL, GL_DYNAMIC_STORAGE_BIT);
    glBindBufferBase(GL_UNIFORM_BUFFER, 0, buffer->ubo);

    return buffer;
}

void set_uniform_data(UniformBuffer* buffer, void* data) {
    glNamedBufferSubData(buffer->ubo, 0, buffer->size, data);
}
