-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmlx_utils.c
30 lines (26 loc) · 1.34 KB
/
mlx_utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mlx_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fflores <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/02 18:54:38 by fflores #+# #+# */
/* Updated: 2020/11/02 18:54:40 by fflores ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void mlx_pix_put(t_data *data, int x, int y, int color)
{
char *pos;
int offset;
offset = y * data->img.line_length + x * (data->img.bits_per_pixel / 8);
pos = data->img.img_addr + offset;
*(unsigned int*)pos = color;
}
unsigned long rgb_hex(int r, int g, int b)
{
if ((r < 0 || r > 255) || (g < 0 || g > 255) || (b < 0 || b > 255))
ft_put_error("\nInvalid color parameters\n", EINVAL);
return ((r & 0xff) << 16) + ((g & 0xff) << 8) + (b & 0xff);
}