-
Notifications
You must be signed in to change notification settings - Fork 1
/
textures.c
48 lines (43 loc) · 1.56 KB
/
textures.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* textures.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mghalmi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/28 11:43:13 by mghalmi #+# #+# */
/* Updated: 2024/02/08 15:46:35 by mghalmi ### ########.fr */
/* */
/* ************************************************************************** */
#include "main.h"
int checkerboard(t_inter *inter)
{
int black;
int white;
t_point coords;
t_point val;
int party_mix;
black = 0x000000;
white = 0xffffff;
coords.x = abs((int)floor(inter->p.x));
coords.y = abs((int)floor(inter->p.y));
coords.z = abs((int)floor(inter->p.z));
val.x = (int)coords.x % 2;
val.y = (int)coords.y % 2;
val.z = (int)coords.z % 2;
party_mix = ((int)val.x ^ (int)val.y) ^ (int)val.z;
if (party_mix)
return (black);
return (white);
}
void define_color(double r, double g, double b, double color[3])
{
color[0] = r;
color[1] = g;
color[2] = b;
}
void apply_texture(int texture, t_inter *inter)
{
if (texture == 1)
inter->color = checkerboard(inter);
}