aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 00:25:57 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 00:25:57 +0100
commit24c048797025d31a23413c69a2e9ed5009e79eaf (patch)
tree6edfa5f053ba16e62cd65c671bb7e84fd9ab04f9 /src
parentOk nice (diff)
download42-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
Diffstat (limited to 'src')
-rw-r--r--src/ft_draw_scene.c9
-rw-r--r--src/ft_exit.c3
-rw-r--r--src/ft_get_music.c4
-rw-r--r--src/ft_treat_args.c12
4 files changed, 19 insertions, 9 deletions
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);
}