Example #1
0
File: main.cpp Project: ElaraFX/tbb
int main (int argc, char *argv[]) {
    try {
        timer mainStartTime = gettimer();

        global_window_title = window_title_string (argc, (const char**)argv);

        argoptions opt = ParseCommandLine(argc, (const char**)argv);

        if ( CreateScene(opt) != 0 )
            return -1;

        tachyon_video tachyon;
        tachyon.threaded = true;
        tachyon.init_console();

        tachyon.title = global_window_title;
        // always using window even if(!global_usegraphics)
        global_usegraphics = 
            tachyon.init_window(global_xwinsize, global_ywinsize);
        if(!tachyon.running)
            return -1;

        video = &tachyon;
        tachyon.main_loop();

        utility::report_elapsed_time(timertime(mainStartTime, gettimer()));
        return 0;
    } catch ( std::exception& e ) {
        std::cerr<<"error occurred. error text is :\"" <<e.what()<<"\"\n";
        return 1;
    }
}
Example #2
0
static int main_init_parts (int argc, char **argv)
{
    int rc;
    argoptions opt;
    char * filename;

    global_window_title = window_title_string (argc, argv);

    global_scene = rt_newscene();

    rt_initialize(&argc, &argv);

    if ((rc = getargs(argc, argv, &opt)) == -1) {
#if _WIN32||_WIN64
        rt_sleep(10000);
#endif
        exit(rc);
    }

#ifdef DEFAULT_MODELFILE
#if  _WIN32||_WIN64
#define _GLUE_FILENAME(x) "..\\dat\\" #x
#else
#define _GLUE_FILENAME(x) #x
#endif
#define GLUE_FILENAME(x) _GLUE_FILENAME(x)
    if(opt.foundfilename == -1)
        filename = GLUE_FILENAME(DEFAULT_MODELFILE);
    else
#endif//DEFAULT_MODELFILE
        filename = opt.filename;

    rc = readmodel(filename, global_scene);

    if (rc != 0) {
        fprintf(stderr, "Parser returned a non-zero error code reading %s\n", filename);
        fprintf(stderr, "Aborting Render...\n");
        rt_finalize();
        return -1;
    }

    /* process command line overrides */
    useoptions(&opt, global_scene);

    // need these early for create_graphics_window() so grab these here...
    scenedef *scene = (scenedef *) global_scene;
    global_xsize = scene->hres;
    global_ysize = scene->vres;
    global_xwinsize = global_xsize;
    global_ywinsize = global_ysize;  // add some here to leave extra blank space on bottom for status etc.
    global_usegraphics = (scene->displaymode == RT_DISPLAY_ENABLED);

    return 0;
}