-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.c
More file actions
59 lines (54 loc) · 1.89 KB
/
init.c
File metadata and controls
59 lines (54 loc) · 1.89 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ishakuro <ishakuro@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/16 12:29:39 by ishakuro #+# #+# */
/* Updated: 2022/04/05 12:41:04 by ishakuro ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
t_map *init_map(void)
{
t_map *map;
map = ft_memalloc(sizeof(t_map));
if (!map)
exit_program(MALLOC_ERROR);
map->width = 0;
map->height = 0;
map->lines_capacity = 16;
map->zoom = 0;
map->lines = ft_memalloc(sizeof(int *) * map->lines_capacity);
if (!map->lines)
exit_program(MALLOC_ERROR);
return (map);
}
t_mlx *init_mlx(t_map *map)
{
t_mlx *mlx;
mlx = (t_mlx *)ft_memalloc(sizeof(t_mlx));
if (!mlx)
exit_program(MLX_ERROR);
mlx->mlx = mlx_init();
if (!mlx->mlx)
exit_program(MLX_ERROR);
mlx->window = mlx_new_window(mlx->mlx, WIN_WIDTH, WIN_HEIGHT, "Fdf");
if (!mlx->window)
exit_program(MLX_ERROR);
mlx->mouse = (t_mouse *)ft_memalloc(sizeof(t_mouse));
if (!mlx->mouse)
exit_program(MALLOC_ERROR);
mlx->img = NULL;
mlx->addr = NULL;
mlx->offset_x = WIN_WIDTH / 2;
mlx->offset_y = WIN_HEIGHT / 2;
mlx->raise_z = 1;
mlx->angle = 0.523599;
mlx->projection = 1;
mlx->onclick = 0;
mlx->map = map;
mlx->map->zoom = WIN_HEIGHT / (mlx->map->width + mlx->map->height);
return (mlx);
}