-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtexture_init.c
More file actions
65 lines (60 loc) · 2.53 KB
/
texture_init.c
File metadata and controls
65 lines (60 loc) · 2.53 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* texture_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bguzel <bguzel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/20 16:59:53 by yturgut #+# #+# */
/* Updated: 2023/09/29 17:27:58 by bguzel ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void start_img(t_data *data)
{
int bpp;
int sizeline;
int endian;
data->img.image = mlx_new_image(data->mlx, SCREEN_WIDTH, SCREEN_HEIGHT);
data->img.data = mlx_get_data_addr(data->img.image, &bpp,
&sizeline, &endian);
data->img.bpp = bpp;
data->img.sizeline = sizeline;
data->img.endian = endian;
}
void open_texture2(t_data *data)
{
data->gun.image = mlx_xpm_file_to_image(data->mlx, "./textures/gun.xpm",
&(data->gun.w), &(data->gun.h));
if (!data->gun.image)
{
printf("Texture gun Error\n");
exit(0);
}
}
void open_textures(t_data *data)
{
data->north.image = mlx_xpm_file_to_image(data->mlx, data->north.path,
&(data->north.w), &(data->north.h));
data->south.image = mlx_xpm_file_to_image(data->mlx, data->south.path,
&(data->south.w), &(data->south.h));
data->west.image = mlx_xpm_file_to_image(data->mlx, data->west.path,
&(data->west.w), &(data->west.h));
data->east.image = mlx_xpm_file_to_image(data->mlx, data->east.path,
&(data->east.w), &(data->east.h));
if (!data->north.image || !data->south.image || !data->west.image
|| !data->east.image)
{
printf("Texture Error\n");
exit(0);
}
data->north.data = mlx_get_data_addr(data->north.image, &(data->north.bpp),
&(data->north.sizeline), &(data->north.endian));
data->south.data = mlx_get_data_addr(data->south.image, &(data->south.bpp),
&(data->south.sizeline), &(data->south.endian));
data->west.data = mlx_get_data_addr(data->west.image, &(data->west.bpp),
&(data->west.sizeline), &(data->west.endian));
data->east.data = mlx_get_data_addr(data->east.image, &(data->east.bpp),
&(data->east.sizeline), &(data->east.endian));
open_texture2(data);
}