#include "linebuffer.hpp"

Linebuffer::Linebuffer()
{
}

Linebuffer::~Linebuffer()
{
    if (vertices)
        delete [] vertices;
}

void Linebuffer::start()
{
    this->list = new Lista2();
    this->vertexcount = 0;
}

void Linebuffer::addVertex(Vector &vertex)
{
    Vector *vert = new Vector(vertex.x, vertex.y, vertex.z);
    this->list->add(vert);
}

void Linebuffer::finalize()
{
    int i;
    this->list->goToStart();
    int count = this->list->getNodeCount();

    this->vertexcount = count;

    vertices = new Vector[count];
    for (i=0;i<count;i++)
    {
        vertices[i] = *(Vector *) this->list->getCurrent();
        this->list->goForward();
    }

    delete this->list;
}