-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
59 lines (54 loc) · 1.97 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jserrano <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/05 14:53:01 by jserrano #+# #+# */
/* Updated: 2020/11/05 15:03:26 by jserrano ### ########.fr */
/* */
/* ************************************************************************** */
#include "raymarching.h"
static void ft_hooks(t_data *param)
{
mlx_hook(param->win_id, KEY_PR, MK_KEY_PR, key_pressed, param);
mlx_hook(param->win_id, BUT_PR, MK_BUT_PR, button_pressed, param);
mlx_hook(param->win_id, BUT_RE, MK_BUT_RE, button_released, param);
mlx_hook(param->win_id, MOT_NT, MK_PTR_MO, get_pos, param);
mlx_hook(param->win_id, CLI_MG, CL_CLOSE, ft_exit, param);
mlx_loop_hook(param->id, show_obj, param);
}
static void main_ifs(t_data *param, int argc, char **argv)
{
if (argc == 3)
{
if (!ft_memcmp(argv[2], "--save", 7))
save_scr(param);
else
write(1, "Enter --save if you want to save a screenshot\n", 47);
ft_exit(param);
}
mlx_loop(param->id);
}
int main(int argc, char **argv)
{
t_data *param;
int i;
if (argc == 2 || argc == 3)
{
i = ft_strlen(argv[1]);
if (ft_memcmp(argv[1] + i - 3, ".rt", 3))
{
write(1, "Please insert correct .rt file\n", 32);
return (-1);
}
param = (t_data *)malloc(sizeof(t_data));
ft_init(param, argv);
ft_hooks(param);
main_ifs(param, argc, argv);
}
else
write(1, "Wrong number of arguments!\n", 28);
return (0);
}