-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource_one.c
74 lines (66 loc) · 1.86 KB
/
source_one.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* source_one.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dkushche <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/02 18:05:01 by dkushche #+# #+# */
/* Updated: 2018/02/02 18:05:01 by dkushche ### ########.fr */
/* */
/* ************************************************************************** */
#include "rtv1.h"
void optimaze_light(t_obj **light)
{
t_obj *tmp;
double count;
count = 0;
tmp = *light;
while (tmp)
{
count += tmp->data[1].x;
tmp = tmp->next;
}
if (count <= 1.0)
return ;
tmp = *light;
while (tmp)
{
tmp->data[1].x /= count;
tmp = tmp->next;
}
}
int my_key_funct(int k, void *param)
{
(void)param;
param = NULL;
if (k == 53)
exit(0);
return (0);
}
int just_exit(void *param)
{
(void)param;
exit(0);
return (1);
}
int main(int argc, char **argv)
{
t_inf inf;
t_camera cam;
t_obj *first;
t_obj *light;
first = NULL;
light = NULL;
(argc == 2) ? 0 : error("I need 1 argument");
inf.mlx = mlx_init();
inf.win = mlx_new_window(inf.mlx, S_WIDTH, S_HEIGHT, "RTv1");
parse(&cam, &first, &light, open(argv[1], O_RDONLY));
optimaze_light(&light);
if (!thread_pow(cam, &first, &light, inf))
return (1);
mlx_hook(inf.win, 2, 0, &(my_key_funct), NULL);
mlx_hook(inf.win, 17, 0, &just_exit, (void *)0);
mlx_loop(inf.mlx);
return (0);
}