#include <Core/Parsing/PARSE_ARGS.h>
#include "QT_MAIN_WINDOW.h"
#include "QT_WINDOW.h"
#include <QApplication>
#include <QMatrix4x4>
#include <QOpenGLShaderProgram>
#include <QScreen>
#include <QtMath>

using namespace PhysBAM;

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    std::string capture_file;
    int begin_frame=0,end_frame=INT_MAX;
    ARRAY<std::string> directories;
    PARSE_ARGS parse_args(argc,argv);
    parse_args.Add("-capture",&capture_file,"file","Perform screen capture and then quit");
    parse_args.Add("-b",&begin_frame,"frame","Start screen capture at this frame");
    parse_args.Add("-e",&end_frame,"frame","End screen capture at this frame");
    parse_args.Extra(&directories,"dir","simulation directory; may specify multiple for screen capture");
    parse_args.Parse();

    PHYSBAM_ASSERT(directories.m>0);

    QT_MAIN_WINDOW window;
    window.show();
    if(capture_file.size())
    {
        window.hide();
        for(auto&d:directories)
        {
            window.Set_Simulation_Directory(d);
            window.window.Capture(d+"/"+capture_file,begin_frame,end_frame);
        }
        return 0;
    }
    else window.Set_Simulation_Directory(directories(0));
    return app.exec();
}
