tinygi

view src/tinygi.h @ 2:72752a1b3dbe

images and shapes
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 21 Jul 2015 04:30:00 +0300
parents bc64090fe3d1
children
line source
1 #ifndef TINYGI_H_
2 #define TINYGI_H_
4 struct tinygi;
5 struct tgi_object;
6 struct tgi_shape;
7 struct tgi_material;
9 struct tinygi *tgi_init(void);
10 void tgi_destroy(struct tinygi *tgi);
12 void tgi_clear_scene(struct tinygi *tgi);
13 int tgi_load_scene(struct tinygi *tgi, const char *fname);
14 /* tinygi takes ownership of added objects */
15 void tgi_add_object(struct tinygi *tgi, struct tgi_object *o);
16 int tgi_remove_object(struct tinygi *tgi, struct tgi_object *o);
18 struct tgi_object *tgi_find_object(struct tinygi *tgi, const char *name);
19 struct tgi_object *tgi_get_object(struct tinygi *tgi, int idx);
20 int tgi_get_object_count(struct tinygi *tgi);
22 /* shapes */
23 struct tgi_shape *tgi_create_sphere(float x, float y, float z, float rad);
24 struct tgi_shape *tgi_create_box(float x0, float y0, float z0, float x1, float y1, float z1);
25 void tgi_destroy_shape(struct tgi_shape *s);
27 /* objects */
28 /* name can be null, in which case it's automatically generated */
29 struct tgi_object *tgi_create_object(const char *name);
30 void tgi_destroy_object(struct tgi_object *o);
31 /* object takes ownership of the shape */
32 void tgi_set_object_shape(struct tgi_object *o, struct tgi_shape *s);
34 /* mat should point to an array of 16 floats (4x4 homogeneous transformation matrix) */
35 void tgi_load_matrix(struct tgi_object *o, const float *mat);
36 void tgi_mult_matrix(struct tgi_object *o, const float *mat);
37 void tgi_load_identity(struct tgi_object *o);
38 void tgi_translate(struct tgi_object *o, float x, float y, float z);
39 void tgi_rotate(struct tgi_object *o, float angle, float x, float y, float z);
40 void tgi_scale(struct tgi_object *o, float x, float y, float z);
41 void tgi_lookat(struct tgi_object *o, float x, float y, float z,
42 float tx, float ty, float tz, float ux, float uy, float uz);
44 /* rendering */
45 float *tgi_begin(struct tinygi *tgi, int width, int height);
46 float *tgi_expose(struct tinygi *tgi, float gamma);
48 void tgi_render_frame(struct tinygi *tgi, int num_samples);
49 void tgi_render(struct tinygi *tgi, int sample_idx);
50 void tgi_render_rect(struct tinygi *tgi, int x, int y, int xsz, int ysz, int sample_idx);
54 #endif /* TINYGI_H_ */