mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
dev: moved my_mlx_get_pixel function in draw utils for easier access
This commit is contained in:
parent
aed03e79c3
commit
7a1e8c18df
4 changed files with 15 additions and 11 deletions
|
|
@ -6,13 +6,21 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:28:56 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/06 11:43:12 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/08/06 14:02:08 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "img_data.h"
|
||||
#include "../consts.h"
|
||||
|
||||
int my_mlx_pixel_get(t_img_data *img, int x, int y)
|
||||
{
|
||||
char *dst;
|
||||
|
||||
dst = img->addr + (y * img->line_length + x * (img->bits_per_pixel / 8));
|
||||
return (*(int *)dst);
|
||||
}
|
||||
|
||||
void my_mlx_pixel_put(t_img_data *data, int x, int y, int color)
|
||||
{
|
||||
char *dst;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:30:04 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 15:57:47 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/08/06 12:08:04 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,5 +16,6 @@
|
|||
# include "img_data.h"
|
||||
|
||||
void my_mlx_pixel_put(t_img_data *data, int x, int y, int color);
|
||||
int my_mlx_pixel_get(t_img_data *img, int x, int y);
|
||||
|
||||
#endif // DRAWUTILS_H
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/31 11:55:41 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/06 11:33:27 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/08/06 14:02:40 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -109,6 +109,7 @@ void raycaster(t_cub3d_data *data, t_ray *ray)
|
|||
calculate_wall_dist(ray, data->map);
|
||||
calculate_wall_height(ray, &data->player);
|
||||
render_walls(data, ray, x);
|
||||
data->zbuffer[x] = ray->wall_dist;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/31 13:17:39 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/05 14:59:24 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/08/06 12:08:33 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "../consts.h"
|
||||
#include "ray.h"
|
||||
#include "../renderer/render.h"
|
||||
#include "../draw/drawutils.h"
|
||||
|
||||
t_cardinal_dir get_cardinal(t_ray *ray)
|
||||
{
|
||||
|
|
@ -33,13 +34,6 @@ t_cardinal_dir get_cardinal(t_ray *ray)
|
|||
}
|
||||
}
|
||||
|
||||
static int my_mlx_pixel_get(t_img_data *img, int x, int y)
|
||||
{
|
||||
char *dst;
|
||||
|
||||
dst = img->addr + (y * img->line_length + x * (img->bits_per_pixel / 8));
|
||||
return (*(int *)dst);
|
||||
}
|
||||
|
||||
static int get_color(t_cub3d_data *data, t_ray *ray, int tex_y)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue