diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_wall_cast.c (renamed from src/ft_draw_verline.c) | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/ft_draw_verline.c b/src/ft_wall_cast.c index 7bfba8d..7610df6 100644 --- a/src/ft_draw_verline.c +++ b/src/ft_wall_cast.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_draw_verline.c :+: :+: :+: */ +/* ft_wall_cast.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ @@ -12,8 +12,9 @@ #include <cub3d.h> #include <stdint.h> +#include <pthread.h> -int8_t +void ft_draw_verline(t_cub *cl, int32_t x, int32_t y, int32_t y2) { int32_t d; @@ -21,15 +22,34 @@ int8_t (y < 0) ? (y = 0) : 0; (y2 < 0) ? (y2 = 0) : 0; - (cl->rlist.line_h <= 0) ? (cl->rlist.line_h = 1) : 0; + (cl->rlist.line_h_tab[x] <= 0) ? (cl->rlist.line_h_tab[x] = 1) : 0; while (y < y2) { - d = y * 256 - cl->wlist.y_size * 128 + cl->rlist.line_h * 128; + d = y * 256 - cl->wlist.y_size * 128 + cl->rlist.line_h_tab[x] * 128; d = (d <= 0) ? (-d) : (d); - tex_y = ((d * cl->tlist[cl->w_side].img_h) / cl->rlist.line_h) / 256; + tex_y = ((d * cl->tlist[cl->rlist.w_side_tab[x]].img_h) + / cl->rlist.line_h_tab[x]) / 256; (tex_y <= 0) ? (tex_y = 1) : 0; ft_draw_texture(cl, x, y, tex_y); y++; } - return (0); +} + +void + *ft_wall_cast(void *vargp) +{ + pthread_t tid[8]; + t_cub *cl; + + cl = (t_cub *)vargp; + pthread_create(&tid[0], 0x0, ft_wall_one, (void*)cl); + pthread_create(&tid[1], 0x0, ft_wall_two, (void*)cl); + pthread_create(&tid[2], 0x0, ft_wall_three, (void*)cl); + pthread_create(&tid[3], 0x0, ft_wall_four, (void*)cl); + pthread_join(tid[0], 0x0); + pthread_join(tid[1], 0x0); + pthread_join(tid[2], 0x0); + pthread_join(tid[3], 0x0); + pthread_exit(0x0); + return (0x0); } |