示例#1
0
文件: main.c 项目: NegMozzie/42
static void		mlx(t_env *e)
{
	mlx_expose_hook(e->win, raycaster, e);
	mlx_hook(e->win, KEYPRESS, KEYPRESSMASK, key_press, e);
	mlx_hook(e->win, KEYRELEASE, KEYRELEASEMASK, key_release, e);
	mlx_loop_hook(e->ptr, key_hook, e);
	mlx_do_key_autorepeatoff(e->ptr);
	mlx_loop(e->ptr);
}
示例#2
0
文件: main.c 项目: mbarbari/RTv1
void		init_env(t_env *env)
{
	env->mlx = mlx_init();
	env->resolution.width = WIDTH;
	env->resolution.height = HEIGHT;
	env->win = mlx_new_window(env->mlx, WIDTH, HEIGHT, "RayTracer");
	env->img.ptr = mlx_new_image(env->mlx, WIDTH, HEIGHT);
	env->img.data = mlx_get_data_addr(env->img.ptr, &env->img.bpp,
			&env->img.sizeline, &env->img.endianness);
	env->fov = 45;
	env->pos_absolute_camera = (t_vertex3){
		.x = json_get(parser(env->file).data.obj, "pos_camera.x").data.number,
		.y = json_get(parser(env->file).data.obj, "pos_camera.y").data.number,
		.z = json_get(parser(env->file).data.obj, "pos_camera.z").data.number};
	env->matrice = malloc(sizeof(t_color3) * (WIDTH * HEIGHT) + 1);
	env->angle = tanf(M_PI * 0.5f * env->fov / 180.);
	env->ratio = env->resolution.width / (float)env->resolution.height;
	env->invw = 1 / (float)env->resolution.width;
	env->invh = 1 / (float)env->resolution.height;
	env->nb_thread = 14;
	env->sampling = 4;
	env->anglex = 0;
	env->angley = 0;
}

int			main(int argc, char **argv)
{
	t_env		env;
	struct stat	file_stat;

	if (argc == 2)
	{
		env.file = argv[1];
		if (stat(env.file, &file_stat) < 0)
		{
			ft_printf("file not exists\n");
			exit(0);
		}
		file_is_modified(env.file, &env.oldtime, 1);
		init_env(&env);
		ft_setup_inter(env.fctinter);
		ft_setup_normal(env.fctnormal);
		mlx_do_key_autorepeatoff(env.mlx);
		mlx_hook(env.win, 2, (1L << 0), &key_press, &env);
		mlx_loop_hook(env.mlx, &loop_hook, &env);
		mlx_expose_hook(env.win, &rt_expose_hook, &env);
		mlx_loop(env.mlx);
		free(env.matrice);
	}
	else
		ft_printf("Usage: %s scene.json\n", argv[0]);
	return (0);
}
示例#3
0
void		ft_wolf(void)
{
	t_display	*e;

	if ((e = malloc(sizeof(t_display))) == NULL)
		return (ft_error("ini_mlx", 0));
	if (ini_mlx(e) == -1)
		return (ft_error("ini_mlx", 0));
	if (ini_display(e) == -1)
		return (ft_error("ini_display", 0));
	mlx_do_key_autorepeatoff(e->mlx);
	mlx_hook(e->win, 2, (1L << 0), &key_hook_press, e);
	mlx_hook(e->win, 3, (1L << 1), &key_hook_release, e);
	mlx_loop_hook(e->mlx, &expose_loop_hook, e);
	mlx_loop(e->mlx);
}
示例#4
0
文件: wolf3d.c 项目: aeddi/wolf3d
int				main(void)
{
	t_data	d;

	if ((d.e.mlx = mlx_init()) == NULL)
		error_printer(NULL);
	d.e.win = mlx_new_window(d.e.mlx, WIDTH, HEIGHT, "Wolf42");
	d.e.img = mlx_new_image(d.e.mlx, WIDTH, HEIGHT);
	if (d.e.win == NULL || d.e.img == NULL)
		error_printer(NULL);
	mlx_expose_hook(d.e.win, expose_event, &d);
	mlx_do_key_autorepeatoff(d.e.mlx);
	mlx_hook(d.e.win, 2, 1, key_press_event, &d);
	mlx_hook(d.e.win, 3, 2, key_release_event, &d);
	mlx_loop_hook(d.e.mlx, loop_event, &d);
	init_map_n_player(&d);
	mlx_loop(d.e.mlx);
	return (0);
}
示例#5
0
文件: main.c 项目: qstemper/42
int				main(int ac, char **av)
{
	t_env		*e;

	e = init_env();
	read_option(e, ac, av);
	if (!(e->mlx.win = mlx_new_window(e->mlx.mlx, WIDTH, HEIGHT, "WOLF3D")))
	{
		ft_putendl("ERROR CREATING WINDOW");
		return (-1);
	}
	usable_key();
	mlx_do_key_autorepeatoff(e->mlx.mlx);
	mlx_loop_hook(e->mlx.mlx, loop_hook, e);
	mlx_hook(e->mlx.win, PRESS, PRESS_MASK, key_press, e);
	mlx_key_hook(e->mlx.win, key_hook, e);
	mlx_loop(e->mlx.mlx);
	return (0);
}
示例#6
0
文件: main.c 项目: Piioupiou/Work
void		ft_mlx(int fd)
{
	t_struct	**matr = NULL;

	matr = ft_creatematr(matr, fd);
	matr[0]->mlx = mlx_init();
	matr[0]->win = mlx_new_window(matr[0]->mlx, 1280, 800, "Wolf3d");
	matr[0]->i = 0;
	matr[0]->image = ft_init_image(matr[0]->image, matr[0]->mlx);
	matr[0]->pproj = ft_init_pproj(matr[0]->pproj);
	matr[0]->player = ft_init_player(matr[0]->player, matr[0]->pproj);
	clear(matr[0]->image, matr);
	ft_go(matr);
	mlx_do_key_autorepeatoff(matr[0]->mlx);
	mlx_expose_hook(matr[0]->win, ft_expose, matr);
	mlx_hook(matr[0]->win, KeyPress, KeyPressMask, ft_mask, matr);
	mlx_hook(matr[0]->win, KeyRelease, KeyReleaseMask, ft_relaise, matr);
	mlx_loop_hook(matr[0]->mlx, ft_key, matr);
	mlx_loop(matr[0]->mlx);
	ft_freeall(matr);
}
示例#7
0
文件: fdf.c 项目: acazuc/42_fdf
int				main(int argc, char **argv)
{
	t_world		*world;

	if (argc != 2)
		error_quit("Invalid parameters.\nUsage:\n./fdf <map_file>");
	if (!(world = malloc(sizeof(*world))))
		error_quit("Failed to malloc world struct");
	world_init(world);
	window_init(world);
	load_map(world, argv[1]);
	world_init_positions(world);
	get_min_max(world);
	mlx_do_key_autorepeatoff(world->window->mlx);
	mlx_hook(world->window->mlx_window, 2, 1, &key_press_listener, world);
	mlx_hook(world->window->mlx_window, 3, 2, &key_release_listener, world);
	mlx_loop_hook(world->window->mlx, &loop_listener, world);
	//mlx_key_hook(world->window->mlx_window, &key_listener, world);
	//mlx_expose_hook(world->window->mlx_window, &expose_listener, world);
	mlx_loop(world->window->mlx);
	return (0);
}