-
Notifications
You must be signed in to change notification settings - Fork 0
/
fdf.c
60 lines (53 loc) · 1.78 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cquillet <cquillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/05 16:29:53 by cquillet #+# #+# */
/* Updated: 2017/10/16 15:38:49 by cquillet ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
#include "libft.h"
int quit_error(const char *s, t_map *map)
{
ft_putstr(s);
if (map)
del_map(map);
ft_putstr("usage: fdf MAP_FILE\n");
return (-1);
}
int exit_fdf(t_fdf *fdf)
{
del_map(&(fdf->map));
mlx_destroy_image(fdf->mlx.mlx, fdf->mlx.win.img.ptr);
mlx_destroy_window(fdf->mlx.mlx, fdf->mlx.win.win);
return (0);
}
int close_and_del_map(const int fd, t_map *map)
{
close(fd);
del_map(map);
return (-1);
}
int close_and_del2dim(const int fd, void ***ptr, unsigned int n)
{
close(fd);
if (ptr)
ft_memdel2dim(ptr, n);
return (-1);
}
t_pixel conv_3d_to_pixel(t_3d point, unsigned int color, t_proj proj)
{
t_vector v;
t_pixel p;
v = create_vector((double)point.x, (double)point.y,
proj.korr_z * (double)point.z);
v = vect_rot(v, proj.rot);
p.x = (int)((v.x - v.y) * proj.zoom);
p.y = (int)((v.x / 2. + v.y / 2. - v.z) * proj.zoom);
p.color = color;
return (p);
}