-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture_reading.c
40 lines (37 loc) · 1.88 KB
/
texture_reading.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* texture_reading.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbrandy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/06 13:30:58 by lbrandy #+# #+# */
/* Updated: 2021/04/03 11:45:38 by lbrandy ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void init_all_text(t_all *all, char *texname, t_datatext *tex)
{
tex->img = mlx_xpm_file_to_image(all->win->mlx, texname,
&tex->width, &tex->height);
if (tex->img > 0)
tex->addr = (char *)mlx_get_data_addr(tex->img, &tex->bpp,
&tex->length, &tex->endian);
else
error_handler("not correct path or extension of file\n");
}
void reading_textures(t_all *all)
{
all->no = (t_datatext *)malloc(sizeof(t_datatext));
all->so = (t_datatext *)malloc(sizeof(t_datatext));
all->we = (t_datatext *)malloc(sizeof(t_datatext));
all->ea = (t_datatext *)malloc(sizeof(t_datatext));
all->s = (t_datatext *)malloc(sizeof(t_datatext));
if (!all->no || !all->so || !all->we || !all->ea || !all->s)
error_handler("malloc error\n");
init_all_text(all, all->textures->no_texture, all->no);
init_all_text(all, all->textures->so_texture, all->so);
init_all_text(all, all->textures->we_texture, all->we);
init_all_text(all, all->textures->ea_texture, all->ea);
init_all_text(all, all->textures->s_texture, all->s);
}