diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | inc/cub3d.h | 3 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 9 | ||||
-rw-r--r-- | src/ft_draw_scene.c | 5 | ||||
-rw-r--r-- | src/ft_init_bmp.c | 27 | ||||
-rw-r--r-- | src/ft_save_to_bmp.c | 2 |
6 files changed, 44 insertions, 3 deletions
@@ -72,6 +72,7 @@ SRCS_NAME += ft_warp_level.c SRCS_NAME += ft_save_to_bmp.c SRCS_NAME += ft_treat_args.c SRCS_NAME += ft_init_funptr.c +SRCS_NAME += ft_init_bmp.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# diff --git a/inc/cub3d.h b/inc/cub3d.h index b1712c1..f7b1a22 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -29,6 +29,7 @@ int ft_init_winptr(t_cub *clist); t_ray ft_init_s_ray(void); t_rgb ft_init_rgb(void); int8_t ft_init_map(t_map *mlist); +t_bmp ft_init_bmp(void); /* ** ====== HOOKS ====== @@ -120,7 +121,7 @@ void ft_set_minimap_scale(t_cub *clist); void *ft_music_thread(void *vargp); void ft_detect(t_cub *cl); void ft_castray(t_cub *cl); -int8_t ft_save_to_bmp(void *img, t_cub *cl); +int8_t ft_save_to_bmp(t_bmp bmp, void *img, t_cub *cl); int ft_error(const char *errmsg, t_cub *clist); uint8_t ft_free_words(char **words); int8_t ft_warp_level(t_cub *cl); diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index ae5ee02..df26c26 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -28,6 +28,15 @@ typedef struct s_win uint32_t y_size; } t_win; +typedef struct s_bmp +{ + uint16_t file_type; + uint32_t file_size; + uint16_t reserv_one; + uint16_t reserv_two; + uint32_t offset_data; +} t_bmp; + typedef struct s_img { void *img; diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c index 78a56b4..9dcc8df 100644 --- a/src/ft_draw_scene.c +++ b/src/ft_draw_scene.c @@ -33,12 +33,15 @@ void void ft_draw_scene_bmp(t_cub *clist) { + t_bmp bmp; + clist->img.img = mlx_new_image(clist->wlist.wlx, clist->wlist.x_size, clist->wlist.y_size); clist->img.ptr = mlx_get_data_addr(clist->img.img, &clist->img.bpp, &clist->img.sizeline, &clist->img.endian); ft_castray(clist); - if (ft_save_to_bmp(clist->img.img, clist) < 0) + bmp = ft_init_bmp(); + if (ft_save_to_bmp(bmp, clist->img.img, clist) < 0) ft_error(FT_ERR_WR_BMP, clist); mlx_destroy_image(clist->wlist.wlx, clist->img.img); } diff --git a/src/ft_init_bmp.c b/src/ft_init_bmp.c new file mode 100644 index 0000000..cc8d59b --- /dev/null +++ b/src/ft_init_bmp.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_init_bmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:28:46 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:28:46 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <cub3d.h> +#include <stdint.h> + +t_bmp + ft_init_bmp(void) +{ + t_bmp bmp; + + bmp.file_type = 0x4d42; + bmp.file_size = 0; + bmp.reserv_one = 0; + bmp.reserv_two = 0; + bmp.offset_data = 0; + return (bmp); +} diff --git a/src/ft_save_to_bmp.c b/src/ft_save_to_bmp.c index 1118384..f69316f 100644 --- a/src/ft_save_to_bmp.c +++ b/src/ft_save_to_bmp.c @@ -30,7 +30,7 @@ static int8_t } int8_t - ft_save_to_bmp(void *img, t_cub *cl) + ft_save_to_bmp(t_bmp bmp, void *img, t_cub *cl) { if (ft_convert_image_to_bmp(img, cl) < 0) return (-1); |