Correction leaks sur un probleme de texture

This commit is contained in:
Etienne Rey-bethbeder 2023-05-19 17:54:06 +02:00
parent 415b6e42e3
commit 42d1359904
9 changed files with 31 additions and 20 deletions

View File

@ -9,7 +9,7 @@ SRCS := ${SRCS_MAP} \
OBJS := ${SRCS:.c=.o} OBJS := ${SRCS:.c=.o}
CC := clang CC := clang
LIBS := libftx/libftx.a MLX42/build/libmlx42.a -ldl -lglfw -lm LIBS := libftx/libftx.a MLX42/build/libmlx42.a -ldl -lglfw -lm
CFLAGS := -g -Wall -Wextra -Werror -Wno-conversion CFLAGS := -g -Wall -Wextra -Werror -Wno-conversion #-Ofast
NAME := cub3D NAME := cub3D
all: ${NAME} all: ${NAME}

View File

@ -6,37 +6,51 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/26 12:59:53 by erey-bet #+# #+# */ /* Created: 2023/04/26 12:59:53 by erey-bet #+# #+# */
/* Updated: 2023/05/11 16:16:00 by erey-bet ### ########.fr */ /* Updated: 2023/05/19 17:49:02 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "game.h" #include "game.h"
void destroy(t_game *game) int destroy(t_game *game)
{
if (game->textures[0])
{ {
mlx_delete_texture(game->textures[0]); mlx_delete_texture(game->textures[0]);
if (game->textures[1])
{
mlx_delete_texture(game->textures[1]); mlx_delete_texture(game->textures[1]);
if (game->textures[2])
{
mlx_delete_texture(game->textures[2]); mlx_delete_texture(game->textures[2]);
if (game->textures[3])
{
mlx_delete_texture(game->textures[3]); mlx_delete_texture(game->textures[3]);
if (game->mlx)
mlx_terminate(game->mlx); mlx_terminate(game->mlx);
} }
}
}
}
return (1);
}
int start_game(t_map map) int start_game(t_map map)
{ {
t_game game; t_game game;
if (init(map, &game)) if (init(map, &game))
return (1); return (destroy(&game));
game.window = mlx_new_image(game.mlx, WIDTH, HEIGHT); game.window = mlx_new_image(game.mlx, WIDTH, HEIGHT);
if (!game.window) if (!game.window)
{ {
mlx_terminate(game.mlx); mlx_terminate(game.mlx);
return (1); return (destroy(&game));
} }
if (mlx_image_to_window(game.mlx, game.window, 0, 0) == -1) if (mlx_image_to_window(game.mlx, game.window, 0, 0) == -1)
{ {
mlx_terminate(game.mlx); mlx_terminate(game.mlx);
return (1); return (destroy(&game));
} }
raycasting(&game); raycasting(&game);
mlx_key_hook(game.mlx, manage, &game); mlx_key_hook(game.mlx, manage, &game);

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 14:50:22 by erey-bet #+# #+# */ /* Created: 2023/04/27 14:50:22 by erey-bet #+# #+# */
/* Updated: 2023/05/11 15:40:16 by erey-bet ### ########.fr */ /* Updated: 2023/05/19 17:03:52 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -55,13 +55,13 @@ int init_textures(t_map map, mlx_texture_t *textures[4])
int init(t_map map, t_game *game) int init(t_map map, t_game *game)
{ {
if (init_textures(map, game->textures))
return (2);
game->mlx = mlx_init(WIDTH, HEIGHT, "jan lili", true); game->mlx = mlx_init(WIDTH, HEIGHT, "jan lili", true);
if (!game->mlx) if (!game->mlx)
return (1); return (1);
game->map = map; game->map = map;
init_ply(map, &game->ply); init_ply(map, &game->ply);
init_ray(&game->ray); init_ray(&game->ray);
if (init_textures(map, game->textures))
return (1);
return (0); return (0);
} }

BIN
libftx/extra/extra.a Normal file

Binary file not shown.

BIN
libftx/gnl/get_next_line.a Normal file

Binary file not shown.

BIN
libftx/libft/libft.a Normal file

Binary file not shown.

BIN
libftx/libftx.a Normal file

Binary file not shown.

BIN
libftx/printf/ft_printf.a Normal file

Binary file not shown.

9
main.c
View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/26 12:44:55 by erey-bet #+# #+# */ /* Created: 2023/04/26 12:44:55 by erey-bet #+# #+# */
/* Updated: 2023/05/05 14:48:45 by cchauvet ### ########.fr */ /* Updated: 2023/05/19 17:03:29 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,15 +22,12 @@ int main(int argc, char **argv)
ft_eprintf("No argument"); ft_eprintf("No argument");
return (1); return (1);
} }
if (map_parsing(argv[1], &map)) if (map_parsing(argv[1], &map)
|| start_game(map))
{ {
map_freer(&map); map_freer(&map);
return (2); return (2);
} }
if (start_game(map))
{
return (3);
}
map_freer(&map); map_freer(&map);
return (0); return (0);
} }