示例#1
0
int			ft_keyhook(int keycode, t_mlx *mlx)
{
	if ((keycode >= 123 && keycode <= 126) || (keycode == 69 || keycode == 78))
		mlx_clear_window(mlx->init, mlx->win);
	if (keycode == 53)
	{
		ft_free_bundle(mlx);
		mlx_destroy_window(mlx->init, mlx->win);
		exit(0);
	}
	else if (keycode == 35)
		mlx->vmp = ft_draw_map(mlx->vmp, mlx);
	else if (keycode == 126)
		ft_draw_map(ft_shift_up(mlx->vmp), mlx);
	else if (keycode == 125)
		ft_draw_map(ft_shift_down(mlx->vmp), mlx);
	else if (keycode == 124)
		ft_draw_map(ft_shift_right(mlx->vmp), mlx);
	else if (keycode == 123)
		ft_draw_map(ft_shift_left(mlx->vmp), mlx);
	else if (keycode == 69)
		ft_draw_map(ft_z_in(mlx->vmp), mlx);
	else if (keycode == 78)
		ft_draw_map(ft_z_out(mlx->vmp), mlx);
	return (0);
}
示例#2
0
void	ft_clear_mlx(t_mlx *mlx)
{
	mlx_destroy_image(mlx->p_mlx, mlx->mlx_img);
	mlx_clear_window(mlx->p_mlx, mlx->p_win);
	mlx_destroy_window(mlx->p_mlx, mlx->p_win);
	ft_memdel((void **)&mlx);
}
示例#3
0
文件: hooks.c 项目: r-maury/Wolf3D
int		key_hook(int keycode, t_mlx *mlx)
{
	if (keycode == 53)
	{
		if (mlx->init == 1)
			free(mlx->map);
		mlx_destroy_image(mlx->mlx, mlx->img);
		mlx_destroy_window(mlx->mlx, mlx->win);
		free(mlx);
		exit(0);
	}
	if (keycode >= 83 && keycode <= 86)
	{
		switch_map(mlx, keycode);
		if (mlx->init == 0 || (mlx->init == -1 && keycode == 83))
		{
			mlx->map = map_select(mlx);
			draw_map(mlx);
		}
	}
	if (mlx->init == 1)
		move(mlx, keycode);
	if (keycode == 17)
		respawn(mlx);
	return (0);
}
示例#4
0
文件: rt.c 项目: mathieu74/Source
static int	key_hook(int keycode, t_rt *s_rt)
{
	t_object	*s_prev_object;
	t_spot		*s_prev_spot;

	if (keycode == ESC)
	{
		mlx_destroy_window(s_rt->mlx_ptr, s_rt->win_ptr);
		mlx_destroy_image(s_rt->mlx_ptr, s_rt->s_img.img_ptr);
		while (s_rt->s_object)
		{
			s_prev_object = s_rt->s_object;
			if (s_rt->s_object->s_img.img_ptr)
				mlx_destroy_image(s_rt->mlx_ptr, s_rt->s_object->s_img.img_ptr);
			s_rt->s_object = s_rt->s_object->s_next;
			free(s_prev_object);
		}
		while (s_rt->s_spot)
		{
			s_prev_spot = s_rt->s_spot;
			s_rt->s_spot = s_rt->s_spot->s_next;
			free(s_prev_spot);
		}
		exit(EXIT_SUCCESS);
	}
	return (0);
}
示例#5
0
int		end_exe(t_e *e)
{
	mlx_destroy_image(e->mlx, e->ima);
	mlx_destroy_window(e->mlx, e->win);
	ft_putendl("So long, and thanks for all the fish");
	exit(0);
	return (0);
}
示例#6
0
文件: key_press.c 项目: qstemper/42
static void		key_quit(t_env *e)
{
	mlx_destroy_window(e->mlx.mlx, e->mlx.win);
	mlx_destroy_image(e->mlx.mlx, e->mlx.img);
	free(*e);
	free(e);
	exit(0);
}
示例#7
0
文件: MlxLib.cpp 项目: Geod24/Nibbler
MlxLib::~MlxLib(void)
{
  if (_mlx && _win)
    mlx_destroy_window(_mlx, _win);
  if (_img)
    free(_img); // No damn mlx_destroy_image
  free(_mlx);
}
示例#8
0
文件: mainator.c 项目: gabfou/RT
static int	key_hook(int keycode, t_env *e)
{
	if (keycode == 53)
	{
		mlx_clear_window(e->mlx, e->win);
		mlx_destroy_window(e->mlx, e->win);
		exit(0);
	}
	return (0);
}
示例#9
0
文件: window.c 项目: Siyanda-Mzam/rt
int		onkey_handler(int key, t_interface *env)
{
	if (key == ESC)
	{
		//mlx_destroy_image(env->gui.mlx, env->gui.image);
		mlx_destroy_window(env->gui.mlx, env->gui.win);
		ft_exit(0, ANSI_GREEN"Info: Now exiting the program"ANSI_GREEN);
	}
	return (key);
}
示例#10
0
int		ft_key_print(int key, t_struct *s)
{
	key_rgb(key, s);
	if (key == 85)
	{
		init_color(s);
		s->color++;
		if (s->color == 6)
		s->color = 0;
	}
	if (key == 53)
	{
		exit(2);
		mlx_destroy_image(s->mlx, s->ptr_img);
		mlx_destroy_window(s->mlx, s->win);
	}
	if (key == 125)
		s->y1 *= 1.01;
	if (key == 126)
		s->y1 *= 0.99;
	if (key == 124)
		s->x1 -= 0.01;
	if (key == 123)
		s->x1 += 0.01;
	if (key == 69)
	{
		s->iter_max += 1;
		s->zoom *= 1.05;
	}
	if (key == 78)
	{
		s->iter_max -= 1;
		s->zoom *= 0.97;
	}
	if (key == 75)
		s->iter_max += 1;
	if (key == 67)
		s->iter_max -= 1;
	if (key == 83)
	{
		s->type++;
		s->bol = 0;
		if (s->type == 5)
			s->type = 1;
	}
	if (key == 84)
	{
		if (s->bw == 1)
		s->bw = 0;
		else
		s->bw = 1;
	}
	put_img(s);
	return (1);
}
示例#11
0
文件: event.c 项目: McM1k/Fract_ol
int		destroy_funct(void *param)
{
	t_env	*env;

	env = (t_env *)param;
	mlx_destroy_image(env->mlx, env->ig);
	mlx_destroy_window(env->mlx, env->win);
	ft_putendl("Closing program.");
	exit(0);
	return (1);
}
示例#12
0
文件: hooks.c 项目: sbran/42
int		key(int bouton, t_param **param)
{
  if (bouton == 65307)
    {
      mlx_destroy_window((*param)->mlx_ptr, (*param)->win_ptr);
      free_list(*param);
      exit(0);
    }
  param = param;
  return (0);
}
示例#13
0
文件: main.c 项目: naimac/wireframe
int		key_function(int keycode, t_param *param)
{
	if (keycode == 53)
	{
		mlx_destroy_image(param->mlx, param->img);
		mlx_destroy_window(param->mlx, param->win);
		free(param);
		exit(EXIT_SUCCESS);
	}
	return (keycode);
}
示例#14
0
文件: main.c 项目: matt2905/raytracer
static int		ft_key_hook(int keycode, t_data *d)
{
	if (keycode == 65307)
	{
		mlx_destroy_image(d->mlx, d->img);
		mlx_destroy_window(d->mlx, d->win);
		ft_destroy_data(d);
		exit(EXIT_SUCCESS);
	}
	return (1);
}
示例#15
0
文件: mlx.c 项目: Infornia/RayTracing
void			destroy_mlx(t_data *d)
{
	if (d->img)
		mlx_destroy_image(d->mlx, d->img);
	if (d->win)
		mlx_destroy_window(d->mlx, d->win);
	if (d->mlx)
	{
		free(d->mlx);
		exit(0);
	}
}
示例#16
0
文件: gere.c 项目: SylTi/school
int		gere_key(int keycode, void *param)
{
  t_mlx		*p;

  p = param;
  if (keycode == ESC)
    {
      mlx_destroy_image(p->mlx, p->img);
      mlx_destroy_window(p->mlx, p->win);
      exit (0);
    }
  return (1);
}
示例#17
0
void	ft_destroy(t_mlxdata *data)
{
	int i;

	i = 0;
	while (i < data->grid->columns)
		free(data->grid->table[i++]);
	free(data->grid->table);
	mlx_destroy_image(data->env.mlx, data->img.ptr);
	mlx_destroy_window(data->env.mlx, data->env.window);
	free(data->grid);
	free(data->env.mlx);
	free(data);
}
示例#18
0
文件: option3.c 项目: joboyer/jojoboy
void	ft_free_all(t_pos *wolf)
{
	mlx_destroy_image(wolf->head->mlx, wolf->head->img);
	mlx_destroy_window(wolf->head->mlx, wolf->head->win);
	ft_free_map(wolf);
	ft_init_jojo(wolf->head);
	free(wolf->head);
	ft_init_val(wolf, 1);
	free(wolf->val);
	ft_init_val2(wolf, 1);
	if (wolf->val2 != NULL)
		free(wolf->val2);
	free(wolf);
}
示例#19
0
void			ft_3denvdel(t_3denv *e)
{
    if (e)
    {
        if (e->mlx)
        {
            if (e->win)
                mlx_destroy_window(e->mlx, e->win);
            if (e->img.buff)
                ft_imgclr(&e->img, e->mlx);
            free(e->mlx);
        }
        free(e);
    }
}
示例#20
0
文件: evo.c 项目: sbenning42/42
int			evo_key(int key, void *p)
{
	t_env	*e;

	e = (t_env *)p;
	if (key == QUITKEY)
	{
		ft_lstdel(&e->pop, NULL);
		evo_success(e->av, "evo destroy pop");
		mlx_destroy_window(e->mlx, e->win);
		evo_success(e->av, "mlx destroy window");
		evo_success(e->av, "mlx loop");
		exit(EXIT_SUCCESS);
	}
	ft_fprintf(2, "[%d]\n", key);
	return (0);
}
示例#21
0
文件: main.c 项目: Raphy42/Fractol
int				main(int argc, char **argv)
{
	t_fract		f;

	ft_bzero(&f, sizeof(t_fract));
	get_args(argc, argv, &f);
	init_env(&f);
	if (getppid() == 0)
		usage();
	f.render_mode(&f);
	mlx_mouse_hook(f.win, &mouse_hook, &f);
	mlx_hook(f.win, KEY_PRESS, KEY_PRESS_MASK, key_hook, &f);
	mlx_hook(f.win, MOTION_NOTIFY, PTR_MOTION_MASK, motion_hook, &f);
	mlx_loop(f.mlx);
	mlx_destroy_window(f.mlx, f.win);
	return (0);
}
示例#22
0
void			ft_free_all(t_env *e)
{
	int			i;

	i = 0;
	while (e->map && e->map[i])
		free(e->map[i++]);
	if (e->map)
		free(e->map);
	e->map = NULL;
	if (e->img)
		mlx_destroy_image(e->mlx, e->img);
	e->img = NULL;
	if (e->win)
		mlx_destroy_window(e->mlx, e->win);
	e->win = NULL;
}
示例#23
0
文件: fdf_key.c 项目: qstemper/42
void		destroy_window(void *p)
{
	t_env	*e;
	int		j;

	e = (t_env *)p;
	mlx_destroy_window(e->mlx, e->win);
	ft_lstdel(&(e->list), NULL);
	j = 0;
	while (j <= e->y_max)
	{
		free(e->mat[j]);
		j++;
	}
	free(e->mat);
	exit(0);
}
示例#24
0
void		screen_init(t_box *box, int id)
{
	t_cmplx a;

	ft_bzero(&a, sizeof(t_cmplx));
	if (box->img != NULL)
		mlx_destroy_image(box->mlx, box->img);
	if (box->win != NULL)
		mlx_destroy_window(box->mlx, box->win);
	init(box, id);
	if (id == 1 || id == 3 || id == 5 || id == 7 || id == 9)
		print_mandelbrot(box, id);
	else if (id == 2 || id == 4 || id == 6 || id == 8 || id == 10)
		print_julia(box, id, &a);
	mlx_hook(box->win, 2, (1L << 0), command2, box);
	mlx_hook(box->win, 6, (1L << 6), mouse_command, box);
	mlx_mouse_hook(box->win, mouse_click, box);
	mlx_put_image_to_window(box->mlx, box->win, box->img, 0, 0);
}
示例#25
0
文件: key.c 项目: qstemper/42
void	key_mv(t_env *e, int keycode)
{
	if (keycode == MOVE_UP || keycode == MOVE_UP2)
		e->player.mv_up = !(e->player.mv_up);
	if (keycode == MOVE_DOWN || keycode == MOVE_DOWN2)
		e->player.mv_down = !(e->player.mv_down);
	if (keycode == MOVE_LEFT || keycode == MOVE_LEFT2)
		e->player.mv_left = !(e->player.mv_left);
	if (keycode == MOVE_RIGHT || keycode == MOVE_RIGHT2)
		e->player.mv_right = !(e->player.mv_right);
	if (keycode == JUMP && e->player.mv_jump == 0)
		e->player.mv_jump = 1;
	if (keycode == ESC)
	{
		mlx_destroy_image(e->mlx.mlx, e->mlx.img);
		mlx_destroy_window(e->mlx.mlx, e->mlx.win);
		exit(0);
	}
}
示例#26
0
文件: key.c 项目: miniponps/42-FdF
int				key_hook(int keycode, t_env *e)
{
	if (keycode == 53)
	{
		mlx_destroy_window(e->mlx, e->win);
		ft_close(e);
	}
	if (keycode == 18)
		e->cam->fov += -10;
	if (keycode == 19)
		e->cam->fov += 10;
	if (keycode == 20)
		e->space += -2;
	if (keycode == 21)
		e->space += 2;
	key_rotation(keycode, e);
	key_move(keycode, e);
	draw(e);
	return (0);
}
示例#27
0
int		free_and_quit(t_fractol *e)
{
	int	i;

	if (e->wins)
	{
		i = -1;
		while (e->wins[++i])
		{
			if (e->wins[i]->img)
				mlx_destroy_image(e->mlx, e->wins[i]->img);
			if (e->wins[i]->win)
				mlx_destroy_window(e->mlx, e->wins[i]->win);
			free(e->wins[i]);
		}
		free(e->wins);
	}
	if (e->mlx)
		free(e->mlx);
	exit(0);
	return (0);
}
示例#28
0
int			key_hook(int k, t_env *e)
{
	key_zoom(k, e);
	key_move(k, e);
	key_reset(k, e);
	if (k == KEY_DEEP_ADD)
		e->i_max += 10;
	if (k == KEY_DEEP_SUB)
		e->i_max -= 10;
	if (k == KEY_AUTO_ZOOM)
		e->zoom_auto = !e->zoom_auto;
	if (k == KEY_PSYCHEDELIC)
		e->psychedelic = !e->psychedelic;
	if (k == KEY_ESC)
	{
		mlx_destroy_window(e->mlx, e->win);
		exit(0);
	}
	if (k == KEY_MOUSE_STOP)
		e->mouse_stop = !e->mouse_stop;
	e->fractal(e);
	return (0);
}
示例#29
0
文件: hooks.c 项目: aempisse/42
int			key_hook(int keycode, t_env *env)
{
//	printf("%d\n", keycode);
	if (keycode == 65307)
	{
		ft_memset(env->img->data, 0, env->img->width * env->img->height * 
			env->img->opp);
		free(env->img);
		mlx_destroy_window(env->mlx, env->win);
		exit(0);
	}
	else if (keycode == 65361)
		env->offset.x -= 50;
	else if (keycode == 65363)
		env->offset.x += 50;
	else if (keycode == 65362)
		env->offset.y -= 50;
	else if (keycode == 65364)
		env->offset.y += 50;
	else if (keycode == 65365)
		env->loop += 5;
	else if (keycode == 65366)
		env->loop -= 5;
	else if (keycode == 'c')
		ft_switch_color(env);
	else if (keycode == 32)
		env->julia_motion = (env->julia_motion ? 0 : 1);
	else if (keycode == 'r')
	{
		env->offset = (t_lpt){env->start_pos.x, env->start_pos.y};
		env->zoom = 200;
	}
	else
		return(0);
	env->renderer = 1;
	return (0);
}
示例#30
0
文件: main.c 项目: mdos-san/wolf3d
int	key_win3(int key,void *p)
{
  printf("Key in Win3 : %d\n",key);
  if (key==0xFF1B)
    mlx_destroy_window(mlx,win3);
}