view TaskManager/Test/test_render/main.cpp @ 268:2b7d631695ca draft

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 04 Jun 2009 00:00:09 +0900
parents e3b7776b1420
children 1fd0107ebb25
line wrap: on
line source

#include "TaskManager.h"
#include "viewer.h"
#include "viewerSDL.h"
#include "viewerFB.h"
#include "Func.h"

/* prototype */
int init(int argc, char *argv[]);

extern void task_initialize();

Viewer *screen;

static int sg_number = 0;

static const char *help_str = "Usage: ./test_nogl [OPTION]\n\
  -cpu Number of SPE (default 1)\n\
  -width, -height window size (default 640x480)\n\
  -sg Draw SceneGraph\n\
      0: Joystick の 丸ボタン(Keyboard だとx) を押すと、キューブが二つに分かれる\n\
      1: 0 のキューブが大きい版\n\
      2: スネークさんが写るだけ 576x384 版\n\
      3: スネークさんが写るだけ 800x600 版\n\
      4: 何かの画像 1920x1080\n\
      5 以降: キューブが跳ね返りながら、勝手にキューブが増えて行く";

int
init(int argc, char *argv[])
{
    int bpp    = 32;
    int width  = 640;
    int height = 480;
    int spenum = 1;
    const char *xml  = "xml_file/cube.xml";
    video_type vtype = VTYPE_SDL;

    for(int i = 1; argv[i]; ++i)
    {
	if (strcmp(argv[i], "-bpp") == 0) {
	    bpp = atoi(argv[++i]);
	}
	if (strcmp(argv[i], "-width") == 0) {
	    width = atoi(argv[++i]);
	} 
	if (strcmp(argv[i], "-height") == 0) {
	    height = atoi(argv[++i]);
	}
	if (strcmp(argv[i], "-xml") == 0) {
	    xml = argv[++i];
	}
	if (strcmp(argv[i], "-sg") == 0) {
	    sg_number = (atoi)(argv[++i]);
	}
	if (strcmp(argv[i], "-cpu") == 0) {
	    spenum = atoi(argv[++i]);
	}
	if (strcmp(argv[i], "-help") == 0) {
	    printf("%s\n", help_str);
	    return -1;
	}
	if (strcmp(argv[i], "-video") == 0) {
	    if (strcmp(argv[i+1], "sdl") == 0) { 
		vtype = VTYPE_SDL;
	    } else if (strcmp(argv[i+1], "fb") == 0) {
		vtype = VTYPE_FB;
	    }
	    i++;
	}
    }

    if (vtype == VTYPE_SDL) {
	screen = new ViewerSDL(bpp, width, height, spenum);
    } else if (vtype == VTYPE_FB) {
	screen = new ViewerFB(bpp, width, height, spenum);
    }

    screen->video_init();
    screen->run_init(xml, sg_number);

    return 0;
}

int
cerium_main(int argc, char *argv[])
{
    task_initialize();

    return init(argc, argv);

    //return 0;
}