15static void draw_ceiling(
t_frame *frame,
int x,
int ceiling_end)
20 while (y < ceiling_end)
22 my_mlx_pixel_put(frame->img_3d, x, y, *frame->ceiling_color);
27static void draw_floor(
t_frame *frame,
int x,
int floor_start)
32 while (y < IMG_3D_HEIGHT)
34 my_mlx_pixel_put(frame->img_3d, x, y, *frame->floor_color);
39static int get_color_texture_pixel(
t_frame *frame,
int tex_x,
int tex_y)
45 img_tex = frame->dda.texture.img_tex;
46 offset = (tex_y * img_tex.line_length) + (tex_x * (img_tex.bpp / 8));
47 color = *(
int *)(img_tex.addr + offset);
52int get_texture_y_coordinate(
t_frame *frame,
int y)
59 line_height = frame->wall_slice.line_height;
60 tex_height = frame->dda.texture.height;
63 d = (y * 256) - (IMG_3D_HEIGHT * 128) + (line_height * 128);
66 tex_y = ((d * tex_height) / line_height) / 256;
69 if (tex_y > tex_height)
77void draw_vertical_line(
t_frame *frame,
int x)
84 tex_x = frame->dda.tex_x;
85 if (x < 0 || x >= IMG_3D_WIDTH)
87 if (frame->wall_slice.draw_start < 0)
88 frame->wall_slice.draw_start = 0;
89 if (frame->wall_slice.draw_end >= IMG_3D_HEIGHT)
90 frame->wall_slice.draw_end = IMG_3D_HEIGHT;
91 y = frame->wall_slice.draw_start;
92 draw_ceiling(frame, x, y);
93 while (y <= frame->wall_slice.draw_end)
95 tex_y = get_texture_y_coordinate(frame, y);
96 color = get_color_texture_pixel(frame, tex_x, tex_y);
97 my_mlx_pixel_put(frame->img_3d, x, y, color);
100 draw_floor(frame, x, frame->wall_slice.draw_end);
single still image for render_frame
3D or 2D or Texture image