feat: adding the loading of texture
This commit is contained in:
parent
761178fcae
commit
646a95451d
4 changed files with 48 additions and 4 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
|
/* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/11/13 06:56:05 by bgoulard ### ########.fr */
|
/* Updated: 2024/11/20 13:55:10 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
# define BONUS 0
|
# define BONUS 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# define TILES_SIZE 64
|
||||||
|
|
||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
|
|
||||||
/// @brief Createsa a blank map for rapahael to test the raycasting
|
/// @brief Createsa a blank map for rapahael to test the raycasting
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/11/08 23:55:29 by bgoulard #+# #+# */
|
/* Created: 2024/11/08 23:55:29 by bgoulard #+# #+# */
|
||||||
/* Updated: 2024/11/12 15:03:39 by rparodi ### ########.fr */
|
/* Updated: 2024/11/20 15:13:28 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ typedef struct s_map
|
||||||
t_ipoint size;
|
t_ipoint size;
|
||||||
t_tile *map;
|
t_tile *map;
|
||||||
char **fraw;
|
char **fraw;
|
||||||
t_img texture[4];
|
t_img *texture[4];
|
||||||
t_color bg_colors[2];
|
t_color bg_colors[2];
|
||||||
} t_map;
|
} t_map;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/11/10 05:33:08 by bgoulard #+# #+# */
|
/* Created: 2024/11/10 05:33:08 by bgoulard #+# #+# */
|
||||||
/* Updated: 2024/11/11 21:45:35 by bgoulard ### ########.fr */
|
/* Updated: 2024/11/20 15:13:32 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
42
mlx_layer/mlx_load_texture.c
Normal file
42
mlx_layer/mlx_load_texture.c
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* mlx_load_texture.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/20 12:25:45 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/11/20 15:20:23 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "cub3d.h"
|
||||||
|
#include "mlx_functions.h"
|
||||||
|
|
||||||
|
t_img *mlx_load_image(t_info *info, char *path)
|
||||||
|
{
|
||||||
|
t_img *image;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
size = TILES_SIZE;
|
||||||
|
image = mlx_xpm_file_to_image(info->mlx_ptr, path, &size, &size);
|
||||||
|
if (!image)
|
||||||
|
return (NULL);
|
||||||
|
return (image);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mlx_load_all_textures(t_info *info)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
info->map.texture[0] = mlx_load_image(info, "../textures/a.xpm");
|
||||||
|
info->map.texture[1] = mlx_load_image(info, "../textures/b.xpm");
|
||||||
|
while (i < 4)
|
||||||
|
{
|
||||||
|
if (!info->map.texture[i])
|
||||||
|
return (false);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue