cub3d/src/utils/destroy_utils.c

47 lines
1.7 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* destroy_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/18 13:05:31 by kcolin #+# #+# */
/* Updated: 2025/08/18 13:05:31 by kcolin ### ########.fr */
/* */
/* ************************************************************************** */
#include "../cub3d_data.h"
#include "../../mlx/mlx.h"
#include <stdlib.h>
void destroy_textures(t_cub3d_data *data)
{
if (data->no_texture)
mlx_destroy_image(data->mlx, data->no_texture->img);
free(data->no_texture);
if (data->so_texture)
mlx_destroy_image(data->mlx, data->so_texture->img);
free(data->so_texture);
if (data->ea_texture)
mlx_destroy_image(data->mlx, data->ea_texture->img);
free(data->ea_texture);
if (data->we_texture)
mlx_destroy_image(data->mlx, data->we_texture->img);
free(data->we_texture);
}
void destroy_sprites(t_cub3d_data *data)
{
int sprite;
sprite = 0;
if (data->sprite_list == NULL)
return ;
while (data->sprite_list[sprite] && sprite < MAX_SPRITES)
{
mlx_destroy_image(data->mlx, data->sprite_list[sprite]->image->img);
free(data->sprite_list[sprite]->image);
free(data->sprite_list[sprite]);
sprite++;
}
}