-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtv1.c
61 lines (55 loc) · 1.92 KB
/
rtv1.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rtv1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sboeuf <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/02/16 19:21:07 by sboeuf #+# #+# */
/* Updated: 2014/02/16 21:07:37 by sboeuf ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/rtv1.h"
void display_scene(void)
{
t_win *window;
window = init_env();
window->img = init_img();
ft_draw_img();
mlx_put_image_to_window(window->mlx, window->win, window->img->img, 0, 0);
mlx_hook(window->win, 2, (1L << 0), ft_key_hook, window);
mlx_expose_hook(window->win, ft_expose_hook, window);
mlx_loop(window->mlx);
}
void rtv1(char *scene_file)
{
init_scene(scene_file);
display_scene();
}
void init_scene(char *scene_file)
{
int fd;
int ret;
char *line;
t_scene *s;
if ((fd = open(scene_file, O_RDONLY)) == -1)
exit(-1);
s = get_scene();
while ((ret = get_next_line(fd, &line)) > 0)
{
if (!ft_strcmp("camera:", line))
s->cam = get_camera(fd);
if (!ft_strcmp("spheres:", line))
s->spheres = get_spheres(fd);
if (!ft_strcmp("planes:", line))
s->planes = get_planes(fd);
if (!ft_strcmp("spots:", line))
s->lights = get_spots(fd);
if (!ft_strcmp("cylinders:", line))
s->cylinders = get_cylinders(fd);
if (!ft_strcmp("cones:", line))
s->cones = get_cones(fd);
}
if (ret == -1)
exit(-1);
}