//------------------------------------------------------------------------------
//  Copyright 2007-2014 by Jyh-Ming Lien and George Mason University
//  See the file "LICENSE" for more information
//------------------------------------------------------------------------------


#include "main.h"
#include "raytracer.h"

//
//
//
//
//   The MAIN function
//
//
//
//

int main(int argc, char ** argv)
{
    //
    if(!parseArg(argc,argv)){
        printUsage(argv[0]);
        return 1;
    }

    //read models
    initialize(rt_filename);
    //

    /////////////////////////////////////////////////////////////////
    //
    // Ray trace rendering here
    //
    /////////////////////////////////////////////////////////////////
    string imagename = "CS451_PA01_Ray_Casting";
    imagename = imagename + "_" + to_string(time(NULL)) + "_.ppm";
    cout << "- Creating image (" << imagename << ") of size " << image_w << "X" << image_h << " with " << n_ray << " rays per pixel" << endl;

    RayTracer rt(models, ambient_light, light_sample_size);
    rt.render(camera, image_w, image_h, n_ray, max_ray_depth);

    cout << "- Saving image (" << imagename << ")" << endl;
    rt.save2file(imagename);

    //debug only
    //all_rays.swap(rt.all_rays);
    //all_intersection_points.swap(rt.intersection_points);
    //debug only

    return 0;
}

