Esempio n. 1
0
void con_init_display(font_t font, texture_t conback)
{
	font_free(con_default->font);
	texture_put(con_default->conback);

	con_default->font = font;
	con_default->conback = conback;
	if (con_default->conback) {
		con_printf("using conback (%d x %d)\n", texture_height(con_default->conback), texture_width(con_default->conback));
	}
	
	con_default->cvars = cvar_ns_new("console");

	cvar_register_uint(con_default->cvars, "lines", CVAR_FLAG_SAVE_NOTDEFAULT, &con_display_lines);

	cvar_ns_load(con_default->cvars);
}
Esempio n. 2
0
static void *ctor(renderer_t r, void *common)
{
	struct _world *world = NULL;
	vec3_t spawn;

	world = calloc(1, sizeof(*world));
	if ( NULL == world )
		goto out;

	world->render = r;
	renderer_viewangles(r, 45.0, 45.0, 0.0);

	world->map = map_load(r, "data/maps/level1");
	if ( NULL == world->map )
		goto out_free;

	spawn[0] = 0.0;
	spawn[1] = CHOPPER_HEIGHT;
	spawn[2] = 0.0;

	world->apache = chopper_comanche(spawn, 0.785);
	if ( NULL == world->apache )
		goto out_free_map;

	world->light = light_new(r, LIGHT_CAST_SHADOWS);
	if ( NULL == world->light ) {
		goto out_free_chopper;
	}

	world->font = font_load(r, "data/font/carbon.png", 16, 16);
	if ( NULL == world->font )
		goto out_free_light;

	world->lightRate = 1440;
	world->light_ticks = 10;

	world->cvars = cvar_ns_new("world");
	if ( NULL == world->cvars )
		goto out_free_font;
		
	cvar_register_float(world->cvars, "time", CVAR_FLAG_SAVE_ALWAYS, &world->lightAngle);
	cvar_register_float(world->cvars, "lightRate", CVAR_FLAG_SAVE_NOTDEFAULT, &world->lightRate);
	cvar_register_uint(world->cvars, "tpf", CVAR_FLAG_SAVE_NOTDEFAULT, &world->light_ticks);
		
	cvar_ns_load(world->cvars);

	world->fcnt = (world->lightAngle / (M_PI / world->lightRate));
	world->fcnt *= world->light_ticks;
	
	/* success */
	goto out;

out_free_font:
	font_free(world->font);
out_free_light:
	light_free(world->light);
out_free_chopper:
	chopper_free(world->apache);
out_free_map:
	map_free(world->map);
out_free:
	free(world);
	world = NULL;
out:
	return world;
}