initial commit
[erebus] / liberebus / src / erebus.h
1 /*
2 erebus - photorealistic renderer
3 Copyright (C) 2018 John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #ifndef LIBEREBUS_H_
19 #define LIBEREBUS_H_
20
21 struct erebus;
22
23 enum erb_option {
24         ERB_OPT_WIDTH,
25         ERB_OPT_HEIGHT,
26         ERB_OPT_MAX_ITER,
27         ERB_OPT_MAX_SAMPLES,
28         ERB_OPT_NUM_THREADS,
29         ERB_OPT_GAMMA,
30
31         ERB_NUM_OPTIONS
32 };
33
34 struct erb_render_status {
35         long progress_percent;          /* derived from the data below */
36         long blocks, max_blocks;        /* completed pixel blocks in current sample pass */
37         long samples, max_samples;      /* completed samples in current frame */
38         long frames, max_frames;        /* completed frames in multi-frame job */
39 };
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 struct erebus *erb_init(void);
46 void erb_destroy(struct erebus *ctx);
47
48 void erb_clear(struct erebus *ctx);
49
50 void erb_setopti(struct erebus *ctx, enum erb_option opt, int val);
51 void erb_setoptf(struct erebus *ctx, enum erb_option opt, float val);
52 void erb_setoptfv(struct erebus *ctx, enum erb_option opt, float *vec);
53
54 int erb_getopti(struct erebus *ctx, enum erb_option opt);
55 float erb_getoptf(struct erebus *ctx, enum erb_option opt);
56 float *erb_getoptfv(struct erebus *ctx, enum erb_option opt);
57
58 float *erb_get_framebuffer(struct erebus *ctx);
59
60 void erb_begin_frame(struct erebus *ctx, long ms);
61 void erb_end_frame(struct erebus *ctx);
62
63 int erb_render(struct erebus *ctx, long timeout);
64 int erb_render_rect(struct erebus *ctx, int x, int y, int width, int height, long timeout);
65
66 int erb_get_progress(struct erebus *ctx);
67 int erb_get_status(struct erebus *ctx, struct erb_render_status *stat);
68
69 int erb_load_scene(struct erebus *ctx, const char *fname);
70 /*int erb_proc_cmd(struct erebus *ctx, const char *cmd);*/
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif  /* LIBEREBUS_H_ */