-
Notifications
You must be signed in to change notification settings - Fork 0
/
fdf.c
77 lines (72 loc) · 2.32 KB
/
fdf.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rerayyad <rerayyad@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/05 14:03:35 by rerayyad #+# #+# */
/* Updated: 2023/05/19 11:58:11 by rerayyad ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void ft_switch_to_iso(float *x, float *y, float *z, double n)
{
*x = (*x - *y) * cos(n);
*y = (*x + *y) * sin(n) - (*z);
}
int ft_canvas_launcher(t_canvas *mlx)
{
mlx->win_x = X;
mlx->win_y = Y;
mlx->scale = (Y / (mlx->height + 3));
mlx->z_scale = 1;
mlx->angle = 0.7853980;
mlx->isometric = 1;
mlx->mlx_ptr = mlx_init();
if (!mlx->mlx_ptr)
return (MLX_ERROR);
mlx->win_ptr = \
mlx_new_window (mlx->mlx_ptr, mlx->win_x, mlx->win_y, "FdF");
if (!mlx->win_ptr)
return (MLX_ERROR);
mlx->offset_x = 500;
mlx->offset_y = 250;
mlx->offset_x_iso = 650;
mlx->offset_y_iso = 150;
mlx->img.alpha = 0;
mlx->img.beta = 0;
mlx->img.gamma = 0;
mlx->rot = 0;
mlx->img.img = mlx_new_image(mlx->mlx_ptr, X, Y);
mlx->img.id = mlx_get_data_addr(mlx->img.img, &mlx->img.bpp, \
&mlx->img.len, &mlx->img.endian);
return (1);
}
int main(int ac, char *av[])
{
int fd;
char *line;
t_canvas mlx;
line = NULL;
fd = open (av[1], O_RDONLY, 0);
get_next_line(fd, &line);
if ((ac != 2) || !ft_extension_check(av[1])
|| fd <= 0 || !line || line[0] == '\n')
ft_false_input(ac, fd, line);
free (line);
fd = open (av[1], O_RDONLY, 0);
mlx.fdf = ft_maps_reader(av[1], fd);
mlx.n = 0;
mlx.height = ft_height(av[1]);
if (!ft_canvas_launcher(&mlx))
{
close (fd);
free(mlx.win_ptr);
ft_cleaner(&mlx.fdf, ft_height(av[1]));
return (0);
}
ft_drawzilla(mlx.fdf, &mlx, ft_height(av[1]));
ft_keylogger(&mlx, ft_height(av[1]), 1);
return (0);
}