-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtexture.c
31 lines (28 loc) · 1.35 KB
/
texture.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* texture.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ajaehaer <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/14 17:51:51 by ajaehaer #+# #+# */
/* Updated: 2019/03/08 17:34:27 by ejommy ### ########.fr */
/* */
/* ************************************************************************** */
#include "engine_render.h"
int get_color_uv(t_texture texture, t_uv uv)
{
size_t i;
size_t j;
if (texture.image == NULL)
{
return (texture.color);
}
i = ((texture.inv_vert ? 1. - uv.v : uv.v) * texture.image->height);
j = ((texture.inv_hor ? 1. - uv.u : uv.u) * texture.image->width);
if (i > texture.image->height)
i = texture.image->height;
if (j > texture.image->width)
j = texture.image->width;
return (texture.image->image_data[i * texture.image->width + j]);
}