aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-23 22:06:00 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-23 22:06:00 +0100
commitc786ace26fb4a041a43b2149b61c11b1c75ba1ca (patch)
tree69f33f8a7e67a5f6214a38b15eea3541b317d7d4 /src/ft_raycasting.c
parentnow pthread (diff)
download42-cub3d-c786ace26fb4a041a43b2149b61c11b1c75ba1ca.tar.gz
42-cub3d-c786ace26fb4a041a43b2149b61c11b1c75ba1ca.tar.bz2
42-cub3d-c786ace26fb4a041a43b2149b61c11b1c75ba1ca.tar.xz
42-cub3d-c786ace26fb4a041a43b2149b61c11b1c75ba1ca.tar.zst
42-cub3d-c786ace26fb4a041a43b2149b61c11b1c75ba1ca.zip
Some threads
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r--src/ft_raycasting.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 99fabeb..89cc61f 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -15,6 +15,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
+#include <pthread.h>
static void
ft_calc_tex(t_cub *cl)
@@ -89,31 +90,32 @@ static void
void
ft_castray(t_cub *cl)
{
+ pthread_t tid[2];
uint16_t i;
- if (!(cl->rlist.wall_dist_tab =
- (float*)malloc(sizeof(float) * cl->wlist.x_size)))
+ if (!(cl->rlist.wall_dist_tab = (float*)malloc(cl->wlist.x_size *
+ sizeof(float))) ||
+ !(cl->rlist.wall_bz = (int16_t*)malloc(cl->wlist.x_size *
+ sizeof(int16_t))) ||
+ !(cl->rlist.w_side_tab = (uint8_t*)malloc(cl->wlist.x_size *
+ sizeof(uint8_t))) ||
+ !(cl->rlist.line_h_tab = (uint16_t*)malloc(cl->wlist.x_size *
+ sizeof(uint16_t))) ||
+ !(cl->rlist.wall_t_tab = (int16_t*)malloc(cl->wlist.x_size *
+ sizeof(int16_t))) ||
+ !(cl->rlist.tex_x_tab = (int32_t*)malloc(cl->wlist.x_size *
+ sizeof(int32_t))))
return ;
- if (!(cl->rlist.wall_bz =
- (int16_t*)malloc(cl->wlist.x_size * sizeof(int16_t))))
- return ;
- cl->rlist.w_side_tab = (uint8_t*)malloc(cl->wlist.x_size * sizeof(uint8_t));
- cl->rlist.line_h_tab = (uint16_t*)malloc(cl->wlist.x_size * sizeof(uint16_t));
- cl->rlist.wall_t_tab = (int16_t*)malloc(cl->wlist.x_size * sizeof(int16_t));
- cl->rlist.tex_x_tab = (int32_t*)malloc(cl->wlist.x_size * sizeof(int32_t));
i = 0;
while (i < cl->wlist.x_size)
{
ft_castray_loop(i, &cl->wlist, cl);
i++;
}
- i = 0;
- while (i < cl->wlist.x_size)
- {
- ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_bz[i]);
- i++;
- }
- ft_floor_cast(cl);
+ pthread_create(&tid[0], 0x0, ft_wall_cast, (void*)cl);
+ pthread_create(&tid[1], 0x0, ft_floor_cast, (void*)cl);
+ pthread_join(tid[0], 0x0);
+ pthread_join(tid[1], 0x0);
ft_calc_sprite(cl);
ft_calc_heal(cl);
ft_calc_trap(cl);