-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
executable file
·89 lines (82 loc) · 2.33 KB
/
main.c
File metadata and controls
executable file
·89 lines (82 loc) · 2.33 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvelluet <mvelluet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/26 11:49:43 by mvelluet #+# #+# */
/* Updated: 2017/03/24 23:06:04 by mvelluet ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void ft_initialisation(t_mlx_fdf *ap)
{
int bpp;
int s_l;
int endian;
ap->mlx = mlx_init();
ap->height = HEIGHT;
ap->width = WIDTH;
ap->win = mlx_new_window(ap->mlx, ap->width, ap->height, "mlx 42");
ap->ptr_img = mlx_new_image(ap->mlx, ap->width, ap->height);
ap->img_str = mlx_get_data_addr(ap->ptr_img, &(bpp), &(s_l), &(endian));
ap->x = 0;
ap->y = 0;
ap->red = 250;
ap->green = 250;
ap->blue = 250;
ap->alpha = 0;
ap->ax = 35.000000;
ap->ay = 340.000000;
ap->az = -35.000000;
ap->zoom = 5;
ap->marge_x = 200;
ap->marge_y = 200;
ap->error = 0;
ap->coef = 1.0;
}
int ft_verif_arg(int argc, char **argv)
{
int len;
if (argc != 2)
return (1);
len = ft_strlen(argv[1]);
len--;
if (argv[1][len] != 'f')
return (1);
if (argv[1][len - 1] != 'd')
return (1);
if (argv[1][len - 2] != 'f')
return (1);
if (argv[1][len - 3] != '.')
return (1);
return (0);
}
int main(int argc, char **argv)
{
t_mlx_fdf ap;
if (ft_verif_arg(argc, argv) == 1)
{
ft_putstr("Error\n");
return (0);
}
ft_initialisation(&ap);
ft_map(argv, &ap);
if (ap.error == 1 || HEIGHT > 1200 || WIDTH > 1200)
{
ft_putstr("Error\n");
return (0);
}
ft_malloc_map(&ap);
ft_malloc_map_coord(&ap);
ft_map_read_2(argv, &ap);
ft_init_map(&ap);
ft_register_hight(&ap);
ft_draw_map(&ap);
ft_link_point(&ap);
mlx_put_image_to_window(ap.mlx, ap.win, ap.ptr_img, 0, 0);
mlx_hook(ap.win, 2, (1L << 0), ft_key_event, &ap);
mlx_loop(ap.mlx);
return (0);
}