Example #1
0
void init_graphic(void) {
	global* global_handle = global_get_singleton();

	config* config_handle = NULL;
	config_alloc(&config_handle, "config/graphics.cfg");

	int resx = config_get_int_value(config_handle, "resx");
	int resy = config_get_int_value(config_handle, "resy");
	int samples = config_get_int_value(config_handle, "msaa");
	int windowed = config_get_int_value(config_handle, "windowed");
	int vsync = config_get_int_value(config_handle, "vertical_sync");

	config_free(&config_handle);

	window* window_handle = NULL;
	window_alloc(&window_handle, resx, resy, samples, !windowed, vsync, 1);

	window_set_blend_mode(window_handle, WINDOW_BLEND_ALPHA);
	window_set_clear_color(window_handle, 0.0f, 0.0f, 0.0f, 0.0f);

	global_set(global_handle, GLOBAL_WINDOW, window_handle);

	hl_render* hl_render_handle = NULL;
	hl_render_alloc(&hl_render_handle);

	global_set(global_handle, GLOBAL_HL_RENDER, hl_render_handle);

	// effect* effect_motion_blur_handle = NULL;
	// effect_alloc(&effect_motion_blur_handle, effect_motion_blur_init, effect_motion_blur_render, effect_motion_blur_config, effect_motion_blur_free, window_get_width(window_handle), window_get_height(window_handle));
	// hl_render_add_effect(hl_render_handle, effect_motion_blur_handle, WINDOW_BLEND_ALPHA);

	camera* camera_handle = NULL;
	camera_alloc(&camera_handle);

	camera_set_dimension(camera_handle, CAMERA_SIZE * (float) window_get_width(window_handle) / (float) window_get_height(window_handle), CAMERA_SIZE);
	camera_set_position(camera_handle, 0.0f, 0.0f);

	camera_update_matrices(camera_handle);

	global_set(global_handle, GLOBAL_CAMERA, camera_handle);

	shader* shader_texture_handle = NULL;
	shader_alloc(&shader_texture_handle, SHADER_TEXTURE_VS, SHADER_TEXTURE_PS);

	global_set(global_handle, GLOBAL_SHADER_TEXTURE, shader_texture_handle);

	text* text_handle = NULL;
	text_alloc(&text_handle, camera_handle, window_handle);

	global_set(global_handle, GLOBAL_TEXT, text_handle);

	input* input_handle = NULL;
	input_alloc(&input_handle, window_handle);

	global_set(global_handle, GLOBAL_INPUT, input_handle);

	debug_draw* debug_draw_handle = NULL;
	debug_draw_alloc(&debug_draw_handle, hl_render_handle);

	global_set(global_handle, GLOBAL_DEBUG_DRAW, debug_draw_handle);
}
Example #2
0
File: camera.c Project: bjorndm/ekq
/** Alocates a new camera. */                                      
Camera * camera_new(Vec3d at, Vec3d look, Point size, float fov) {
  Camera * me = camera_alloc();
  return camera_init(me, at, look, size, fov);
}