diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-13 00:25:57 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-13 00:25:57 +0100 |
commit | 24c048797025d31a23413c69a2e9ed5009e79eaf (patch) | |
tree | 6edfa5f053ba16e62cd65c671bb7e84fd9ab04f9 | |
parent | Ok nice (diff) | |
download | 42-cub3d-24c048797025d31a23413c69a2e9ed5009e79eaf.tar.gz 42-cub3d-24c048797025d31a23413c69a2e9ed5009e79eaf.tar.bz2 42-cub3d-24c048797025d31a23413c69a2e9ed5009e79eaf.tar.xz 42-cub3d-24c048797025d31a23413c69a2e9ed5009e79eaf.tar.zst 42-cub3d-24c048797025d31a23413c69a2e9ed5009e79eaf.zip |
Better linux compat
-rw-r--r-- | inc/cub3d_defines.h | 5 | ||||
-rw-r--r-- | src/ft_draw_scene.c | 9 | ||||
-rw-r--r-- | src/ft_exit.c | 3 | ||||
-rw-r--r-- | src/ft_get_music.c | 4 | ||||
-rw-r--r-- | src/ft_treat_args.c | 12 |
5 files changed, 22 insertions, 11 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index 2fbd325..1c2c39c 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -84,9 +84,9 @@ enum */ # if FT_OS == 1 -# define FT_MUS_CMD "/usr/bin/afplay --volume 0.2 %s" +# define FT_SND_CMD "/usr/bin/afplay --volume 0.2 %s" # else -# define FT_MUS_CMD "/usr/bin/aplay -f cd -t wav -q %s" +# define FT_SND_CMD "/usr/bin/aplay -f cd -t wav -q %s" # endif /* @@ -138,6 +138,7 @@ enum # define FT_ERR_ALLOCATE "Allocation error" # define FT_ERR_READ "read error" # define FT_ERR_ARGS "too many or to few arguments" +# define FT_ERR_ARGV "Bad arguments" # define FT_ERR_RES_SMALL "resolution is too small, 50x50 minimum pls" # define FT_ERR_RES_ALPHA "resolution should be digits only" # define FT_ERR_SH_ALPHA "shadow amount should be digits only" diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c index 80cd1bc..1edef2a 100644 --- a/src/ft_draw_scene.c +++ b/src/ft_draw_scene.c @@ -41,6 +41,13 @@ static int8_t void ft_draw_scene(t_cub *clist) { + if (FT_OS == 2) + { + 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); + } if (clist->doicast) ft_castray(clist); else @@ -51,6 +58,8 @@ void ft_draw_skybox(clist); mlx_put_image_to_window(clist->wlist.wlx, clist->wlist.winptr, clist->img.img, 0, 0); + if (FT_OS == 2) + mlx_destroy_image(clist->wlist.wlx, clist->img.img); if (clist->ishud && clist->mlist.isnlvl) if (ft_put_stage(clist) < 0) ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist); diff --git a/src/ft_exit.c b/src/ft_exit.c index 4ed318c..3ec26ad 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -73,7 +73,8 @@ int ft_del_tex(clist); if (clist->wlist.inited) { - mlx_destroy_image(clist->wlist.wlx, clist->img.img); + if (FT_OS == 1) + mlx_destroy_image(clist->wlist.wlx, clist->img.img); mlx_destroy_window(clist->wlist.wlx, clist->wlist.winptr); clist->wlist.winptr = NULL; } diff --git a/src/ft_get_music.c b/src/ft_get_music.c index 2383e0a..7a8d36f 100644 --- a/src/ft_get_music.c +++ b/src/ft_get_music.c @@ -21,11 +21,11 @@ static int8_t uint8_t len; len = ft_strlen(mlist->music_path); - len += ft_strlen(FT_MUS_CMD) - 2; + len += ft_strlen(FT_SND_CMD) - 2; ft_memdel((void**)&mlist->music_cmd); if (!(mlist->music_cmd = (char *)malloc((len + 1) * sizeof(char)))) return (-1); - ft_sprintf(mlist->music_cmd, FT_MUS_CMD, + ft_sprintf(mlist->music_cmd, FT_SND_CMD, mlist->music_path); ft_free_words(mlist->mcmd_words); if (!(mlist->mcmd_words = ft_split(mlist->music_cmd, ' '))) diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c index fe794d8..92464ab 100644 --- a/src/ft_treat_args.c +++ b/src/ft_treat_args.c @@ -37,10 +37,13 @@ uint8_t { if (ft_init_winptr(clist) < 0) return (ft_exit(FT_RET_FAILED_MLX, clist)); - clist->img.img = mlx_new_image(clist->wlist.wlx, + if (FT_OS == 1) + { + 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.ptr = mlx_get_data_addr(clist->img.img, &clist->img.bpp, &clist->img.sizeline, &clist->img.endian); + } ft_draw_scene(clist); if (clist->mlist.ismusic) ft_enable_music(clist); @@ -52,9 +55,6 @@ uint8_t return (ft_exit(FT_RET_FINE, clist)); } else - { - ft_dprintf(STDERR_FILENO, "Error\n\033[1;31mBad arguments\n\033[0m"); - return (ft_exit(FT_RET_BAD_ARGV, clist)); - } + return (ft_error(FT_RET_BAD_ARGV, FT_ERR_ARGV, clist)) return (FT_RET_FINE); } |