20static int get_texture_addr(
t_texture *texture, t_type_wall type)
24 img = (
t_img *)&texture[type].img_tex;
25 img->addr = (
char *)mlx_get_data_addr(
26 img->img, &img->bpp, &img->line_length, &img->endian);
27 if (img->addr == NULL)
29 ft_eprintf(
"%s%s\n", ERR_PROMPT, EMSG_IMG_DATA_ADDR);
30 return (EXIT_FAILURE);
32 return (EXIT_SUCCESS);
42static t_type_wall get_type_of_wall(
const char *line,
const char *key[])
47 while (type < ENUM_SOUTH)
49 if (is_key_line(line, key[type]) ==
true)
56int parse_tex(
const char *line,
t_parse *parse)
61 static const char *key[4] = {
"NO ",
"WE ",
"EA ",
"SO "};
62 static const int bit[4] = {BIT_NORTH, BIT_WEST, BIT_EAST, BIT_SOUTH};
64 mlx = parse->game->mlx;
65 texture = parse->game->texture;
66 type = get_type_of_wall(line, key);
67 if (check_duplicate_info(parse->flag, bit[type], line) != EXIT_SUCCESS)
68 return (EXIT_FAILURE);
69 if (create_texture_image(line, parse, type) != EXIT_SUCCESS)
70 return (EXIT_FAILURE);
71 if (get_texture_addr(texture, type) != EXIT_SUCCESS)
73 destroy_texture_image(mlx, texture, parse->flag);
74 return (EXIT_FAILURE);
76 parse->flag |= bit[type];
77 if (check_for_not_matching_bit(parse->flag,
78 BIT_NORTH | BIT_SOUTH | BIT_EAST | BIT_WEST) == 0x00)
79 parse->flag |= BIT_INIT_TEX;
80 return (EXIT_SUCCESS);
3D or 2D or Texture image