#include "linebuffer.hpp"

Linebuffer::Linebuffer()
{
}

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

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

void Linebuffer::addVertex(Vector3 &vertex)
{
    Vector3 *vert = new Vector3(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 Vector3[count];
    for (i=0;i<count;i++)
    {
        vertices[i] = *(Vector3 *) this->list->getCurrent();
        this->list->goForward();
    }

    delete this->list;
}