Example #1
0
int snap_init( void ) {
	const struct config *config = config_get();
	int i;
	noise[0] = sdl_create_texture( DATA_DIR "/pixmaps/noise1.png" );
	noise[1] = sdl_create_texture( DATA_DIR "/pixmaps/noise2.png" );
	noise[2] = sdl_create_texture( DATA_DIR "/pixmaps/noise3.png" );
	
	if( noise[0] == NULL || noise[1] == NULL || noise[2] == NULL ) {
		fprintf( stderr, "Warning: Couldn't create texture for snap noise\n" );
		return -1;
	}
	
	for( i = 0 ; i < NUM_NOISE ; i++ ) {
		noise[i]->width = MAX_SIZE;
		noise[i]->height = MAX_SIZE / ogl_aspect_ratio();
	}
	
	if( config->iface.frame_rate ) {
		noise_skip = config->iface.frame_rate / 10;
		steps = config->iface.frame_rate / 4;
	}
	else {
		steps = MAX_STEPS;
	}
	
	scale = config->iface.theme.snap.size * SCALE_FACTOR;
	platform_scale = config->iface.theme.snap.size * PLATFORM_SIZE;
	
	if( config->iface.theme.snap.offset1 > 0 )
		hidden_offset = -hidden_offset;
	
	return 0;
}
Example #2
0
int snap_set( struct game *game ) {
	const struct config_snap *config = &config_get()->iface.theme.snap;
	char *filename;

	snap_clear();
	texture = NULL;
	video = 0;
	
	platform_texture = game->platform->texture;
	
	filename = game_media_get( game, MEDIA_VIDEO, NULL );
	if( filename && filename[0] ) {
		if( video_open( filename ) == 0 ) {
			video = 1;
			texture = video_texture();
		}
	}
	
	if( !texture ) {
		filename = game_media_get( game, MEDIA_IMAGE, image_type_name(IMAGE_SCREENSHOT) );
		if( filename && filename[0] ) {
			texture = sdl_create_texture( filename );
		}
		else {
			return -1;
		}
	}

	if( texture ) {
		if( config->fix_aspect_ratio ) {
			if( texture->width > texture->height ) {
				/* Landscape */
				width = MAX_SIZE;
				height = MAX_SIZE / ogl_aspect_ratio();
			}
			else {
				/* Portrait */
				height = MAX_SIZE;
				width = MAX_SIZE / ogl_aspect_ratio();
			}				
		}
		else {
			if( texture->width > texture->height ) {
				/* Landscape */
				height = (int)(float)texture->height/((float)texture->width/MAX_SIZE);
				width = MAX_SIZE;
			}
			else {
				/* Portrait */
				width = (int)(float)texture->width/((float)texture->height/MAX_SIZE);
				height = MAX_SIZE;
			}
		}
		return 0;
	}

	return -1;
}
Example #3
0
int bg_set( const char *filename ) {
	if( filename && *filename ) {
		if( bg_texture != bg_clear_texture ) {
			ogl_free_texture( bg_texture );
		}
		bg_texture = sdl_create_texture( filename );
		if( bg_texture == 0 ) {
			fprintf( stderr, "Warning: couldn't load background image '%s'\n", filename );
			return -1;
		}
	}
	else {
		bg_clear();
	}
	return 0;
}
Example #4
0
int game_load_texture( struct game *game ) {	
	const char *filename = game_media_get( game, MEDIA_IMAGE, game_image_type );
	
	if( game->texture ) {
		game_free_texture( game );
	}

	if( game && filename ) {
		game->texture = sdl_create_texture( filename );
	}
	if( game->texture == NULL ) {
		if( game && game->name && *game->name ) {
			game->texture = font_create_texture( game->name );
		}
		else {
			game->texture = font_create_texture( "<No Name>" );
		}
	}

	if( game->texture == NULL ) {
		return -1;
	}
	else {
		if( game->texture->width > game->texture->height ) {
			/* Landscape */
			if( game->texture->width > IMAGE_MAX_WIDTH ) {
				game->texture->height = (int)(float)game->texture->height/((float)game->texture->width/IMAGE_MAX_WIDTH);
				game->texture->width = IMAGE_MAX_WIDTH;
			}
		}
		else {
			/* Portrait (or square) */
			if( game->texture->height > IMAGE_MAX_HEIGHT ) {
				game->texture->width = (int)(float)game->texture->width/((float)game->texture->height/IMAGE_MAX_HEIGHT);
				game->texture->height = IMAGE_MAX_HEIGHT;
			}
		}
	}

	return 0;
}
Example #5
0
int bg_init( void ) {
	const struct config *config = config_get();
	char filename[CONFIG_FILE_NAME_LENGTH];

	if( config->iface.theme.background_image[0] != '\0' ) {
		location_get_theme_path( config->iface.theme.background_image , filename );
		bg_clear_texture = sdl_create_texture( filename );	
		if( bg_clear_texture == NULL ) {
			fprintf( stderr, "Warning: couldn't create background texture from '%s'\n", config->iface.theme.background_image );
			return -1;
		}
	}

	alpha = 1.0 - (GLfloat)(config->iface.theme.background_transparency)/100;
	
	if( config->iface.frame_rate )
		angle_step = (GLfloat)config->iface.theme.background_rotation/((GLfloat)config->iface.frame_rate*20);
	else 
		angle_step = (GLfloat)config->iface.theme.background_rotation/1000;

	bg_clear();
	return 0;
}