diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 18:04:38 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 18:04:38 +0100 |
commit | 50759fcc4f3b939ad35254ce220c206056f3f31e (patch) | |
tree | fd28f91d64ccefe142927eeaf9dc85e5719c3666 /src/ft_draw_textures.c | |
parent | Good tweak (diff) | |
download | 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.gz 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.bz2 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.xz 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.zst 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.zip |
Fixed
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_textures.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c index 126d0af..4bc0b78 100644 --- a/src/ft_draw_textures.c +++ b/src/ft_draw_textures.c @@ -26,22 +26,21 @@ void ft_draw_texture(t_cub *cl, int x, int y, int tex_y) { float dist; - float calc; + t_rgb rgb; if ((dist = cl->rlist.wall_dist) <= 0) dist = 0.0001; - calc = (dist * 0.1 * cl->mlist.darklvl); - calc = (calc >= 255) ? (255) : (calc); - calc = (calc < 1) ? (1) : (calc); - cl->img.ptr[x * 4 + (cl->img.sizeline * y)] = + rgb.b = (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * - cl->tlist[cl->w_side].img_h * tex_y] / calc; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 1] = + cl->tlist[cl->w_side].img_h * tex_y]; + rgb.g = (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * - cl->tlist[cl->w_side].img_h * tex_y + 1] / calc; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 2] = + cl->tlist[cl->w_side].img_h * tex_y + 1]; + rgb.r = (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * - cl->tlist[cl->w_side].img_h * tex_y + 2] / calc; + cl->tlist[cl->w_side].img_h * tex_y + 2]; + *(int*)(cl->img.ptr + ((uint16_t)x * 4 + + (y * cl->img.sizeline))) = ft_rgb_to_hex(dist, rgb, cl); } void |