-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.c
44 lines (40 loc) · 1.38 KB
/
hook.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hook.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: junyojeo <junyojeo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/13 17:34:32 by junyojeo #+# #+# */
/* Updated: 2023/05/19 02:12:24 by junyojeo ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
int key_press(int key, t_mlx *mlx)
{
if (key == KEY_ESCAPE)
{
if (mlx->mlx && mlx->win)
{
mlx_destroy_image(mlx->mlx, mlx->img);
mlx_destroy_window(mlx->mlx, mlx->win);
}
exit(0);
}
return (0);
}
int red_cross(t_mlx *mlx)
{
if (mlx->mlx && mlx->win)
{
mlx_destroy_image(mlx->mlx, mlx->img);
mlx_destroy_window(mlx->mlx, mlx->win);
}
exit(0);
return (0);
}
void ft_hook(t_mlx *mlx)
{
mlx_hook(mlx->win, 2, 0, key_press, mlx);
mlx_hook(mlx->win, 17, 0, red_cross, mlx);
}