コード例 #1
0
ファイル: vision.c プロジェクト: manuelthieme/chopchop
void *visualise(void *shedule) {
    struct jsp **model = shedule;

    if (init_SDL())
        pthread_exit(NULL);

    int running = 1;
    SDL_Event event;

    while (running) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                running = 0;
            }
        }
        pthread_mutex_lock(&mutex);
        if (*model != NULL) {
            draw_model(*model);
        }
        pthread_mutex_unlock(&mutex);
    }

    if (colors) {
        afree(colors);
    }
    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();
    pthread_exit(NULL);
}
コード例 #2
0
ファイル: main.c プロジェクト: te-bachi/cgr
int main(int argc, char* argv[]) {
	// If intialising of SDL fails -> quit the program with error code 1
	if (!init_SDL()) {
		quit_program(1);
	}
	
	// If intialising of OpenGL fails -> quit the program with error code 1
	if (!init_OpenGL(default_width, default_height)) {
		quit_program(1);
	}
	
	// Repeat forever
	while(true) {
		// Draw your graphics
		draw_screen();
		
		// Process any ocuring events 
		process_events();
		fflush(stdout);
	}
	
	// You shouldn't get here. Only if someone changes the while condition...
	quit_program(0);
	
	return 0;
}
コード例 #3
0
ファイル: OVR_SDL2_app.cpp プロジェクト: MORTAL2000/OVR_SDL2
OVR_SDL2_app::OVR_SDL2_app() : hmd(0), eye(ovrEye_Left), window(0)
{
    if (init_OVR())
    {
        running = init_SDL(hmd->WindowsPos.x,
                           hmd->WindowsPos.y,
                           hmd->Resolution.w,
                           hmd->Resolution.h);
        conf_OVR();
    }
}
コード例 #4
0
ファイル: gp2xsdk.cpp プロジェクト: alfredox123/pifba
void pi_initialize() {

    pi_initialize_input();
    pi_parse_config_file();

    init_SDL();

    //Initialise display just for the rom loading screen first.
    pi_setvideo_mode(320, 240);
    pi_video_flip();

}
コード例 #5
0
    void asdf_multiplat_t::init(std::string _exec_dir) {
        LOG("--- Initializing This Crazy Contraption ---");

        running = true;

        exec_dir = _exec_dir;
        working_directory = get_current_working_directory();
        SetCurrentDir(exec_dir.c_str());

        LOG("Exec Dir: %s", exec_dir.c_str());
        LOG("Working Dir: %s", working_directory.c_str());

        init_SDL();
        in_focus = true;

        renderer = make_unique<asdf_renderer_t>();
        renderer->init();

        Content.init();
        spritebatch = make_shared<spritebatch_t>();
        spritebatch->spritebatch_shader = Content.shaders["spritebatch"];

        main_view = make_shared<ui_view_t>(glm::vec2(0, 0), glm::vec2(settings.resolution_width, settings.resolution_height));
    }
コード例 #6
0
ファイル: main.c プロジェクト: mathias-steiger/4dgame_testing
int mainloop(void*)
{
	int drawchange = 0; int refreshdelay[2] = {33, 33}; int rdelay = 33;
	Uint32 time1 = SDL_GetTicks(), time2 = SDL_GetTicks();
	float ts; int u; int i;
	
	if(!init_SDL(surface))
	{ fprintf(stderr, "SDL_OPENGL failed\n"); exit(1);}
	if(!initGL(w_width, w_height))
	{ fprintf(stderr, "OpenGL failed\n"); exit(1);}

	SDL_WM_SetCaption( "Tesseract", NULL );

	glPointSize(8.0f);

	resizewindow(1280, 1024); 

	load_textures();

	lbounds[0] = 10;
	ts = lbounds[0];

	q = (Quaternion*)(malloc(9999999*sizeof(Quaternion)));
	qbuffer = (Quaternion*)(malloc(9999*sizeof(Quaternion)));
	quatnum = 0;

//	quatnum += construct_tesseract(1,1,1,1, 0, 0, 0, 1,quatnum, 0.5);
playerpost.set(0,0,0,0);
	float acc = fack;

	float spp[18] = { 
		0,
		0, 
		(GLfloat)iterations, // 255 iterations
		0.35f,
		0,
		F_QUATMANDEL,
		-acc+playerpost.a,
		acc+playerpost.a,
		-acc+playerpost.b,
		acc+playerpost.b,
		-acc+playerpost.c,
		acc+playerpost.c,
		-acc+playerpost.d,
		acc+playerpost.d,
		acc,
		zoom2,
		tesseract,
		simplex
		};

	if(points)
		{
			quatnum = calc_fractal(spp, q);
		}
	else
		quatnum += construct_tesseract(1,1,1,1, 0, 0, 0, 0,quatnum, 0.5);

	bquat = quatnum; 
	t_size = quatnum;
/*
	quatnum += construct_tesseract(1,1,1,1, -ts,  ts,  ts,  ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts, -ts,  ts,  ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts,  ts, -ts,  ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts,  ts,  ts,  ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts, -ts, -ts,  ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1, -ts, -ts,  ts,  ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1, -ts,  ts, -ts,  ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1, -ts, -ts, -ts,  ts,quatnum, 0.5);

	quatnum += construct_tesseract(1,1,1,1, -ts,  ts,  ts,  -ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts, -ts,  ts,  -ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts,  ts, -ts,  -ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts,  ts,  ts,  -ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1,  ts, -ts, -ts,  -ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1, -ts, -ts,  ts,  -ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1, -ts,  ts, -ts,  -ts,quatnum, 0.5);
	quatnum += construct_tesseract(1,1,1,1, -ts, -ts, -ts,  -ts,quatnum, 0.5);
*/

	freequat = quatnum; 
//	quatnum += construct_tesseract(1,1,1,1, 0,  0, 0, 0,quatnum, 0.5);

/*
	for(u = 4; u <= 8; u+=2)
	quatnum += construct_tesseract(1,1,1,1, 0,  0, 0, -(5-u*4),quatnum, 1.75);

	for(u = 4; u <= 8; u+=2)
	quatnum += construct_tesseract(1,1,1,1, 0,  0, -(5-u*4), 0,quatnum, 1.75);

	for(u = 4; u <= 8; u+=2)
	quatnum += construct_tesseract(1,1,1,1, 0, -(5-u*4), 0, 0,quatnum, 1.75);

	for(u = 4; u <= 8; u+=2)
	quatnum += construct_tesseract(1,1,1,1, -(5-u*4),  0,  0, 0,quatnum, 1.75);

*/

	movquat = quatnum;

/*
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.8);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 1.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);

	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
	quatnum += construct_tesseract(1,1,1,1, 0,  0,  0, 0,quatnum, 0.1);
*/
	maxquat = quatnum;

	int yy;
	printf("quatnum: %d\n", quatnum);

//	for(u = 0; u < quatnum; u++)
//		qo[u] = q[u];

	playerpos.set(0,0,0,0);
	playerpost.set(0,0,0,0);
	padd.set(0,0,0,0);
	ptemp.set(0,0,0,0);
	ptemp2.set(0,0,0,0);

			randreinit();

	init_fbo(0);	
	init_fbo(1);	
	init_fbo(2);
	
	init_fbo(3);	

	for(i = 0; i < quatnum/4; i++)
	{
		zposbuf[i] = get_zposbuf(i);
		zposbufi[i] = i;
	}

	while(!done)
	{
		framecounter++;
		if(framecounter > 4294967000UL) framecounter = 0;
		drawchange = keylistener();
		SDL_Delay(rdelay*0.5);
		if(!(framecounter%5))
		{
//			printf("Delay: %d\n", rdelay);
			time1 = SDL_GetTicks();
			refreshdelay[framecounter%2] = 
				1000/((((int)(time1-time2)) > 0)
				? (int)(time1-time2) : 1000 );
			time2 = time1;
			if(abs(refreshdelay[framecounter%2]
			- refreshdelay[(framecounter-1)%2])
			>= 2)
			{ 
				rdelay = (refreshdelay[framecounter%2]
				       + refreshdelay[(framecounter-1)%2])/2; 
				rdelay -= 16;
				if(rdelay <= 0) rdelay = 0;
				rdelay = 33;
			}
		}
		if(!(framecounter%((int)(33*20))))
			randreinit();		
		drawGLscene();
	}
	printf("Quit called, cleaning up\n");
	SDL_Quit(); 

	return(0);
}
コード例 #7
0
ファイル: nucleo.cpp プロジェクト: jion/tetrabrick
Nucleo::Nucleo(int i_fullscreen, int i_depth) try
{
    // Inicia la SDL
    init_SDL();

    // Carga la configuracion, los graficos y los utiles
    r_configuration = new Configuration;
    r_galeria       = new Galeria;
    r_utils         = new Utils;

    // Inicia a 0 todo lo referido al subsitema Multiplayer
    d_multiplayer = NULL;
    s_multiplayer = NULL;

    // Crea la Display Surface
    create_DisplaySurface(i_fullscreen, i_depth);

    // Crea las escenas
    e_juego  = new Juego(this);
    e_menu   = new Menu(this);
    e_actual = e_menu;

    // Configuraciones varias
    SDL_EnableKeyRepeat(100, 30); //TODO: Pasarlo directamente a modulo Configuration
    //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

    // Transfiere el control al bucle principal
    bucle_principal();

} catch( exception& e ) throw(e.what());

Nucleo::~Nucleo()
{
    delete galeria;
    delete configuration;
    delete utils:

    delete menu;
	delete juego;

	if(s_multiplayer) delete s_multiplayer;
}

void Nucleo::terminar(int reason)
{
	//TODO: Switch reasons
}

////////////////////////////////////////////////////////////////////////////////
// Privadas
////////////////////////////////////////////////////////////////////////////////


void Nucleo::bucle_principal (void)
{

}

void Nucleo::init_SDL(void)
{
    Uint32 flags = SDL_INIT_VIDEO | SDL_INIT_TIMER;

    // Configura los modulos activados
    if(configuration->audio->enabled) flags |= SDL_INIT_AUDIO;
    if(configuration->input->jostick) flags |= SDL_INIT_JOYSTICK;

    // Inicia la SDL
	if (SDL_Init(flags) == -1) throw std::runtime_error(SDL_GetError());

	// Sale por SDL_Quit
	atexit(SDL_Quit);
}
コード例 #8
0
ファイル: rayviewer.c プロジェクト: kaspermeerts/cg
int main(int argc, char **argv)
{
	Timer *render_timer;
	Sdl *sdl;
	FILE *out;
	Colour *buffer;
	Pixel *pixels;
	int num_pixels;

	SDL_Event event = {0};

	if (argc < 2)
		return 1;

	sdl = sdl_load(argv[1]);
	if (sdl == NULL)
		return 1;

	if (!init_SDL())
		return 1;

	num_pixels = config->width * config->height;
	buffer = calloc(num_pixels, sizeof(Colour));
	pixels = calloc(num_pixels, sizeof(Pixel));
	for (int j = 0; j < config->height; j++)
	for (int i = 0; i < config->width; i++)
	{
		pixels[j*config->width + i].x = i;
		pixels[j*config->width + i].y = j;
	}
	srand(time(NULL));
	shuffle_pixels(pixels, config->width, config->height);
	srand(0x20071208);

	/* START */
	render_timer = timer_start("Rendering");

	for (int i = 0; i < num_pixels; i++)
	{
		Camera *cam = scene->camera;
		Colour c;
		Ray r;
		int x = pixels[i].x, y = pixels[i].y;

		/* The last parameter is the near plane, which is irrelevant for
		 * the moment. */
		r = camera_ray(cam, x, y, 1);

		c = ray_colour(r, 0);

		buffer[config->width*y + x] = c;
		put_pixel(display_surface, x, y, c);
		if (i % config->width == 0)
		{
			SDL_Flip(display_surface);
			while (SDL_PollEvent(&event))
				if (event.type == SDL_QUIT)
					return 0;
		}
	}

	/* STOP */
	timer_stop(render_timer);
	timer_diff_print(render_timer);
	printf("%.2f kilopixels per second\n",
			num_pixels/1000./(timer_diff(render_timer)));

	out = fopen("ray.ppm", "w");
	ppm_write(buffer, config->width, config->height, out);
	free(buffer);
	fclose(out);

	SDL_Flip(display_surface);
	while(1)
	{
		while (SDL_WaitEvent(&event))
			if (event.type == SDL_QUIT)
				return 0;
			else if (event.type == SDL_VIDEOEXPOSE)
				SDL_Flip(display_surface);
	}

	return 0;
}
コード例 #9
0
ファイル: sdl.cpp プロジェクト: AlanApter/steamlink-sdk
int main (int argc, char **argv)
{
	int res, i, j = 0, game_index;
    char *playbackname = NULL;
    char gamenameselection[32];
    int use_cyclone=1;
    int use_drz80_save=0;
   	int use_drz80_snd_save=1;
    int use_drz80;
   	int use_drz80_snd;
    extern int video_scale;
	extern int video_border;
	extern int video_aspect;
	extern int throttle;
	extern int soundcard;
    int use_gui=0;
    int first_run=1;

	kiosk_mode=0;

	{
	    char *abspath = (char*)malloc(PATH_MAX);
		if (!abspath) {
			logerror("Out of memory\n");
		}
	    realpath(argv[0], abspath);
	    char *dirsep = strrchr(abspath, '/');
	    if( dirsep != 0 ) *dirsep = 0;
		chdir(abspath);
		free(abspath);
	}
 
	memset(&options,0,sizeof(options));

	/* these two are not available in mame.cfg */
	errorlog = 0;

	game_index = -1;

	soundcard=-1;

	for (i = 1;i < argc;i++) /* V.V_121997 */
	{
		if (strcasecmp(argv[i],"-log") == 0)
			errorlog = fopen("error.log","wa");
		if (strcasecmp(argv[i],"-nocyclone") == 0)
			use_cyclone=0;
		if (strcasecmp(argv[i],"-drz80") == 0)
			use_drz80_save=1;
		if (strcasecmp(argv[i],"-nodrz80_snd") == 0)
			use_drz80_snd_save=0;
		if (strcasecmp(argv[i],"-scale") == 0)
			video_scale=1;
		if (strcasecmp(argv[i],"-border") == 0)
			video_border=1;
		if (strcasecmp(argv[i],"-aspect") == 0)
			video_aspect=1;
		if (strcasecmp(argv[i],"-nothrottle") == 0)
			throttle=0;
		if (strcasecmp(argv[i],"-nosound") == 0)
			soundcard=0;
        if (strcasecmp(argv[i],"-playback") == 0)
		{
			i++;
			if (i < argc)  /* point to inp file name */
				playbackname = argv[i];
        	}
	}

	if (argc == 1)
		use_gui=1;

	/* check for frontend options */
	if(!use_gui) {
		res = frontend_help (argc, argv);
	
		/* if frontend options were used, return to DOS with the error code */
		if (res != 1234)
		{
			exit (res);
		}
	}

    for (j = 1; j < argc; j++)
    {
        if (argv[j][0] != '-') {
            strcpy(gamenameselection, argv[j]);
            break;
        }
    }

    if(init_SDL()==0) {
        exit(1);
    };
    
gui_loop:
    
    if(use_gui) {
		usleep(1000000/2);
        
        gp2x_joystick_clear();

		//Normally read in the game start but we need some vars
		//setting for the frontend.
		parse_cmdline (argc, argv, 1);
        
        frontend_gui(gamenameselection, first_run);
        
        first_run=0;
        
		usleep(1000000/2);
        
        //Clear input queue
        gp2x_joystick_clear();
    }
    
    /* handle playback which is not available in mame.cfg */
	init_inpdir(); /* Init input directory for opening .inp for playback */

    if (playbackname != NULL)
        options.playback = osd_fopen(playbackname,0,OSD_FILETYPE_INPUTLOG,0);

    /* check for game name embedded in .inp header */
    if (options.playback)
    {
        INP_HEADER inp_header;

        /* read playback header */
        osd_fread(options.playback, &inp_header, sizeof(INP_HEADER));

        if (!isalnum(inp_header.name[0])) /* If first byte is not alpha-numeric */
            osd_fseek(options.playback, 0, SEEK_SET); /* old .inp file - no header */
        else
        {
            for (i = 0; (drivers[i] != 0); i++) /* find game and play it */
			{
                if (strcmp(drivers[i]->name, inp_header.name) == 0)
                {
                    game_index = i;
                    printf("Playing back previously recorded game %s (%s) [press return]\n",
                        drivers[game_index]->name,drivers[game_index]->description);
                    getchar();
                    break;
                }
            }
        }
    }

	/* If not playing back a new .inp file */
    if (game_index == -1)
    {
		/* do we have a driver for this? */
        {
            for (i = 0; drivers[i] && (game_index == -1); i++)
            {
                    if (strcasecmp(gamenameselection,drivers[i]->name) == 0)
                {
                    game_index = i;
                    break;
                }
            }
        }

        if (game_index == -1)
        {
            printf("Game \"%s\" not supported\n", argv[j]);
            return 1;
        }
    }

	/* parse generic (os-independent) options */
	parse_cmdline (argc, argv, game_index);

{	/* Mish:  I need sample rate initialised _before_ rom loading for optional rom regions */
	extern int soundcard;

	if (soundcard == 0) {    /* silence, this would be -1 if unknown in which case all roms are loaded */
		Machine->sample_rate = 0; /* update the Machine structure to show that sound is disabled */
		options.samplerate=0;
	}
}

	/* handle record which is not available in mame.cfg */
	for (i = 1; i < argc; i++)
	{
		if (strcasecmp(argv[i],"-record") == 0)
		{
            i++;
			if (i < argc)
				options.record = osd_fopen(argv[i],0,OSD_FILETYPE_INPUTLOG,1);
		}
	}

    if (options.record)
    {
        INP_HEADER inp_header;

        memset(&inp_header, '\0', sizeof(INP_HEADER));
        strcpy(inp_header.name, drivers[game_index]->name);
        /* MAME32 stores the MAME version numbers at bytes 9 - 11
         * MAME DOS keeps this information in a string, the
         * Windows code defines them in the Makefile.
         */
        /*
        inp_header.version[0] = 0;
        inp_header.version[1] = VERSION;
        inp_header.version[2] = BETA_VERSION;
        */
        osd_fwrite(options.record, &inp_header, sizeof(INP_HEADER));
    }

	/* Replace M68000 by CYCLONE */
	if (use_cyclone)
	{
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if (((*type)&0xff)==CPU_M68000 || ((*type)&0xff)==CPU_M68010 )
			{
				*type=((*type)&(~0xff))|CPU_CYCLONE;
			}
		}
	}

	use_drz80_snd = use_drz80_snd_save;
	use_drz80 = use_drz80_save;	

	// Do not use the DrZ80 core for games that are listed as not compatible
	// in the frontend list
	for (i=0;i<NUMGAMES;i++)
 	{
		if (strcmp(drivers[game_index]->name,fe_drivers[i].name)==0)
		{
			/* ASM cores: 0=None,1=Cyclone,2=DrZ80,3=Cyclone+DrZ80,4=DrZ80(snd),5=Cyclone+DrZ80(snd) */
			if(fe_drivers[i].cores == 0 || fe_drivers[i].cores == 1) 
			{
				use_drz80_snd=0;
				use_drz80=0;
				break;
			}
		}
	}

#if (HAS_DRZ80)
	/* Replace Z80 by DRZ80 */
	if (use_drz80)
	{
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if (((*type)&0xff)==CPU_Z80)
			{
				*type=((*type)&(~0xff))|CPU_DRZ80;
			}
		}
	}

	/* Replace Z80 with DRZ80 only for sound CPUs */
	if (use_drz80_snd)
	{
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if ((((*type)&0xff)==CPU_Z80) && ((*type)&CPU_AUDIO_CPU))
			{
				*type=((*type)&(~0xff))|CPU_DRZ80;
			}
		}
	}
#endif

    /*
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if (((*type)&0xff)==CPU_V30)
			{
				*type=((*type)&(~0xff))|CPU_ARMV30;
			}
		}
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if (((*type)&0xff)==CPU_V33)
			{
				*type=((*type)&(~0xff))|CPU_ARMV33;
			}
		}
    */

    // Remove the mouse usage for certain games
    if ( (strcasecmp(drivers[game_index]->name,"hbarrel")==0) || (strcasecmp(drivers[game_index]->name,"hbarrelw")==0) ||
         (strcasecmp(drivers[game_index]->name,"midres")==0) || (strcasecmp(drivers[game_index]->name,"midresu")==0) ||
         (strcasecmp(drivers[game_index]->name,"midresj")==0) || (strcasecmp(drivers[game_index]->name,"tnk3")==0) ||
         (strcasecmp(drivers[game_index]->name,"tnk3j")==0) || (strcasecmp(drivers[game_index]->name,"ikari")==0) ||
         (strcasecmp(drivers[game_index]->name,"ikarijp")==0) || (strcasecmp(drivers[game_index]->name,"ikarijpb")==0) ||
         (strcasecmp(drivers[game_index]->name,"victroad")==0) || (strcasecmp(drivers[game_index]->name,"dogosoke")==0) ||
         (strcasecmp(drivers[game_index]->name,"gwar")==0) || (strcasecmp(drivers[game_index]->name,"gwarj")==0) ||
         (strcasecmp(drivers[game_index]->name,"gwara")==0) || (strcasecmp(drivers[game_index]->name,"gwarb")==0) ||
         (strcasecmp(drivers[game_index]->name,"bermudat")==0) || (strcasecmp(drivers[game_index]->name,"bermudaj")==0) ||
         (strcasecmp(drivers[game_index]->name,"bermudaa")==0) || (strcasecmp(drivers[game_index]->name,"mplanets")==0) ||
         (strcasecmp(drivers[game_index]->name,"forgottn")==0) || (strcasecmp(drivers[game_index]->name,"lostwrld")==0) ||
         (strcasecmp(drivers[game_index]->name,"gondo")==0) || (strcasecmp(drivers[game_index]->name,"makyosen")==0) ||
         (strcasecmp(drivers[game_index]->name,"topgunr")==0) || (strcasecmp(drivers[game_index]->name,"topgunbl")==0) ||
         (strcasecmp(drivers[game_index]->name,"tron")==0) || (strcasecmp(drivers[game_index]->name,"tron2")==0) ||
         (strcasecmp(drivers[game_index]->name,"kroozr")==0) ||(strcasecmp(drivers[game_index]->name,"crater")==0) ||
         (strcasecmp(drivers[game_index]->name,"dotron")==0) || (strcasecmp(drivers[game_index]->name,"dotrone")==0) ||
         (strcasecmp(drivers[game_index]->name,"zwackery")==0) || (strcasecmp(drivers[game_index]->name,"ikari3")==0) ||
         (strcasecmp(drivers[game_index]->name,"searchar")==0) || (strcasecmp(drivers[game_index]->name,"sercharu")==0) ||
         (strcasecmp(drivers[game_index]->name,"timesold")==0) || (strcasecmp(drivers[game_index]->name,"timesol1")==0) ||
         (strcasecmp(drivers[game_index]->name,"btlfield")==0) || (strcasecmp(drivers[game_index]->name,"aztarac")==0))
    {
        extern int use_mouse;
        use_mouse=0;
    }

    /* go for it */
    printf ("%s (%s)...\n",drivers[game_index]->description,drivers[game_index]->name);
    res = run_game (game_index);

	/* close open files */
	if (errorlog) fclose (errorlog);
	if (options.playback) osd_fclose (options.playback);
	if (options.record)   osd_fclose (options.record);
	if (options.language_file) osd_fclose (options.language_file);

	gp2x_deinit();
    
	game_index = -1;

	if(use_gui) goto gui_loop;
    
	deinit_SDL();
    
	exit (res);
}
コード例 #10
0
ファイル: SDL_main.cpp プロジェクト: Rozz160/3rd-Year-Project
int main(int argc, char* args[])
{
    init_SDL();
    //Starts the menu screen, i==1 is Quit, else turn on the game.
    int i = objloader::showmenu(screen, font);
    if(i==1)
    {
        isRunning=false;
        SDL_Quit();
    }else
    {
        screen = NULL;
        isRunning=true;
    }
    //lets isRunning to true;
    update.start();
    //Creates the threads .
    thread1 = SDL_CreateThread(render, NULL);
    thread2 = SDL_CreateThread(logic, NULL);
    //Create a new Event call object.
    SDL_Event event;
    while(isRunning)
    {
        //Set certain keys to have events attached to them.
        if(SDL_PollEvent(&event))
        {
            if(event.type == SDL_QUIT)
            {
                isRunning = false;
            }
            if(event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_ESCAPE)
            {
                isRunning = false;
            }
            if(event.type == SDL_KEYDOWN)
            {
                if(event.key.keysym.sym == SDLK_RETURN)
                {
                    cap = ( !cap );
                }
                else if(event.key.keysym.sym == SDLK_e)
                {
                    //Scrolls throught the skybox
                    sky.currentSkybox++;
                    if(sky.currentSkybox > 4)
                    {
                        sky.currentSkybox = 0;
                    }
                }
                if(event.key.keysym.sym == SDLK_w)
                {
                    car.up=true;
                }else if(event.key.keysym.sym == SDLK_s)
                {
                    car.down=true;
                }
                if(event.key.keysym.sym == SDLK_a)
                {
                    car.left=true;
                }else if(event.key.keysym.sym == SDLK_d)
                {
                    car.right=true;
                }
            }
            if(event.type == SDL_KEYUP)
            {
                if(event.key.keysym.sym == SDLK_w)
                {
                    car.up=false;
                }else if(event.key.keysym.sym == SDLK_s)
                {
                    car.down=false;
                }
                if(event.key.keysym.sym == SDLK_a)
                {
                    car.left=false;
                }else if(event.key.keysym.sym == SDLK_d)
                {
                    car.right=false;
                }
            }
        }

        SDL_Delay(1000/60);
    }
    //Waits til the threads site
    SDL_WaitThread(thread1, NULL);
    SDL_WaitThread(thread2, NULL);
    //Cleanup handler.
    glDeleteLists(list1, 1);
    glDeleteLists(objCar, 1);
    glDeleteLists(objWheel, 1);
    TTF_CloseFont(font);
    TTF_Quit();
    sky.killSkybox();
    //Exits SDL
    SDL_Quit();

    return(0);
}