#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace sf;

#include "../camera.hpp"
#include "../point.hpp"
#include "../title.hpp"
#include "../shellSTD.hpp"

#define w 800
#define h 600
#define mag 800
#define zfactor 1


int main()
{
    title g;
    RenderWindow* app = new RenderWindow(VideoMode(w, h, 32), "B==D");
    app->SetFramerateLimit(60);

    point posTitre(0,-0.8,0);

    g.setPosTitre(posTitre);
    float ry=0.01,
          rx=0.01;

    while (app->IsOpened())
    {
        Event* event = new Event();
        while (app->GetEvent(*event))
            if (event->Type == Event::Closed)
                app->Close();

        if (app->GetInput().IsKeyDown(Key::Escape))
            return EXIT_SUCCESS;

        g.rotationObjY(ry);
        g.rotationObjZ(rx);

        g.update();
        app->Clear(Color(0,0,0));

        while(g.thereIsLineToDraw())
        {
            camera::draw cam = g.nextLineToDraw();
            Color col = Color(cam._r,
                        cam._g,
                        cam._b);
            Shape Line = Shape::Line(cam._p1X+w/2,
                               cam._p1Y+h/2,
                               cam._p2X+w/2,
                               cam._p2Y+h/2,
                               1, col,
                               0, Color(255,255,255));
            app->Draw(Line);
        }
        //refresh screen
        app->Display();
    }


    return 0;
}
