#include "rendering/ColorRenderer.h"

ColorRenderer::ColorRenderer() : buffer(8 * 1024 * 1024, 2 * sizeof(float) + 4) {
    vertexBuffer.bind();
    int step = 2 * sizeof(float) + 4;
    vertexBuffer.setFloatAttribute(0, 2, 0, step);
    vertexBuffer.setColorAttribute(2, 2 * sizeof(float), step);
}

void ColorRenderer::draw(const Vertex& v1, const Vertex& v2, const Vertex& v3) {
    vertexBuffer.bind();
    buffer.reset(3 * sizeof (float) * 6);
    buffer.add(v1.x).add(v1.y).add(v1.color);
    buffer.add(v2.x).add(v2.y).add(v2.color);
    buffer.add(v3.x).add(v3.y).add(v3.color);
    buffer.draw();
}