#include "rendering/Attributes.h"

Attributes& Attributes::addFloat(int count) {
    attributes.add(GL::Attribute::newFloat(count));
    return *this;
}

Attributes& Attributes::addColor4() {
    attributes.add(GL::Attribute::newColor(4));
    return *this;
}

Attributes& Attributes::addSpacer() {
    attributes.add(GL::Attribute::newDummy());
    return *this;
}

void Attributes::set() const {
    int size = 0;
    for(const GL::Attribute& a : attributes) {
        size += a.getSize();
    }
    int index = 0;
    int offset = 0;
    for(const GL::Attribute& a : attributes) {
        if(!a.isDummy()) {
            GL::vertexAttribPointer(index, a, size, offset);
        }
        offset += a.getSize();
        index++;
    }
}