Shadowrun: Awakened 29 September 2011 - Build 871
Classes | Defines | Functions | Variables
video.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "types.h"
#include "api.h"
#include "getargs.h"
#include "parse.h"
#include "ui.h"
#include "util.h"
#include "video.h"
Include dependency graph for video.cpp:

Go to the source code of this file.

Classes

class  tachyon_video

Defines

#define VIDEO_WINMAIN_ARGS

Functions

int main (int argc, char **argv)
static int main_init_parts (int argc, char **argv)
void rt_finalize (void)
static char * window_title_string (int argc, char **argv)

Variables

static SceneHandle global_scene
static bool global_usegraphics
static char * global_window_title
static int global_xsize
static int global_xwinsize
static int global_ysize
static int global_ywinsize
class videovideo = 0

Define Documentation

Definition at line 68 of file video.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 193 of file video.cpp.

References global_usegraphics, global_window_title, global_xwinsize, global_ywinsize, video::init_console(), video::init_window(), main_init_parts(), video::main_loop(), video::running, video::threaded, video::title, and video::updating.

{
    int rc;

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

    rc = main_init_parts (argc, argv);
    if (rc) return rc;

    tachyon.title = global_window_title;
    tachyon.updating = global_usegraphics;
    // 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();

    return 0;
}
static int main_init_parts ( int  argc,
char **  argv 
) [static]

Definition at line 105 of file video.cpp.

References scenedef::displaymode, argoptions::filename, argoptions::foundfilename, getargs(), global_scene, global_window_title, global_xsize, global_xwinsize, global_ysize, global_ywinsize, scenedef::hres, readmodel(), RT_DISPLAY_ENABLED, rt_finalize(), rt_initialize(), rt_newscene(), rt_sleep(), scene, useoptions(), scenedef::vres, and window_title_string().

Referenced by main().

{
    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;
}
void rt_finalize ( void  )

Definition at line 183 of file video.cpp.

References video::next_frame(), rt_sleep(), timerstart(), timerstop(), and timertime().

Referenced by main_init_parts(), and rtbomb().

                       {
    timerstart();
    if(global_usegraphics)
        do { rt_sleep(10); timerstop(); }
        while(timertime() < 10 && video->next_frame());
#ifdef _WINDOWS
    else rt_sleep(10000);
#endif
}
static char* window_title_string ( int  argc,
char **  argv 
) [static]

Definition at line 85 of file video.cpp.

Referenced by main_init_parts().

{
    int i;
    char *name;

    name = (char *) malloc (8192);
    
    if(strrchr(argv[0], '\\')) strcpy (name, strrchr(argv[0], '\\')+1);
    else if(strrchr(argv[0], '/')) strcpy (name, strrchr(argv[0], '/')+1);
    else strcpy (name, *argv[0]?argv[0]:"Tachyon");
    for (i = 1; i < argc; i++) {
        strcat (name, " ");
        strcat (name, argv[i]);
    }
#ifdef _DEBUG
    strcat (name, " (DEBUG BUILD)");
#endif
    return name;
}

Variable Documentation

Definition at line 77 of file video.cpp.

Referenced by main_init_parts().

Definition at line 83 of file video.cpp.

Referenced by main().

char* global_window_title [static]

Definition at line 82 of file video.cpp.

Referenced by main(), and main_init_parts().

int global_xsize [static]

Definition at line 78 of file video.cpp.

Referenced by main_init_parts().

int global_xwinsize [static]

Definition at line 80 of file video.cpp.

Referenced by main(), and main_init_parts().

int global_ysize [static]

Definition at line 79 of file video.cpp.

Referenced by main_init_parts().

int global_ywinsize [static]

Definition at line 81 of file video.cpp.

Referenced by main(), and main_init_parts().

class video* video = 0

Definition at line 181 of file video.cpp.


Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net