#include <iostream>
#include "Window.h"
#include "Runtime.h"
#include <memory>
#include "System.h"

int main(int argc, char * argv[])
{
    if (!System::init())
    {
        return 1;
    }

    Runtime::init(argv[0], APPNAME);

    const char * filename = nullptr;
    if (argc > 1)
    {
        filename = argv[1];
    }
    std::shared_ptr<Buffer> b = std::make_shared<Buffer>(filename);
    Window w;
    if (!w.create(b))
    {
        std::cerr << "Error creating window." << std::endl;
        return 1;
    }

    w.run_event_loop();

    return 0;
}
