X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=erebus2020;a=blobdiff_plain;f=liberebus%2Fsrc%2Ferebus.h;h=fcb097beed44df038cab97ccd97af0e0ddfb728a;hp=6ec33e3aaa8f3153bad8c5d428e25fe92951593e;hb=399df0323dcd1cafe860565fd82598321aff52ee;hpb=2e09068ea0c58f8a464f8584b2bb4e9f23241e95 diff --git a/liberebus/src/erebus.h b/liberebus/src/erebus.h index 6ec33e3..fcb097b 100644 --- a/liberebus/src/erebus.h +++ b/liberebus/src/erebus.h @@ -3,6 +3,7 @@ #include +struct erb_rend; struct erb_node; struct erb_surf; struct erb_ray; @@ -10,6 +11,7 @@ struct erb_hit; struct erb_aabb; typedef int (*erb_intersect_func)(struct erb_surf *surf, struct erb_ray *ray, struct erb_hit *hit); +typedef void (*erb_hitgeom_func)(struct erb_surf *surf, struct erb_hit *hit); typedef void (*erb_sample_func)(struct erb_surf *surf, cgm_vec3 *pos); typedef void (*erb_bbox_func)(struct erb_surf *surf, struct erb_aabb *bb); @@ -32,6 +34,7 @@ struct erb_surf { int bbox_valid; erb_intersect_func isect; /* intersection routine */ + erb_hitgeom_func hitgeom; /* calculate derived values of the erb_hit structure */ erb_sample_func sample; /* random sample generation */ erb_bbox_func calc_bbox; /* bounds calculation */ @@ -47,11 +50,25 @@ struct erb_ray { struct erb_hit { float t, err; + cgm_vec3 pos, lpos; /* global and local space hit positions */ struct erb_surf *surf; + float total_dist; + + /* derived by calc_hit */ + cgm_vec3 norm, tang; + float u, v; }; -int erb_init(void); -void erb_cleanup(void); +struct erb_rend *erb_create(void); +void erb_destroy(struct erb_rend *erb); + +int erb_allocframe(struct erb_rend *erb, int width, int height); +float *erb_getframe(struct erb_rend *erb); + +/* clears the framebuffer and sample counters to begin rendering a new frame */ +void erb_begin(struct erb_rend *erb); +/* finalizes the frame, averaging samples (optional) */ +float *erb_end(struct erb_rend *erb); /* transformation nodes */ struct erb_node *erb_node(void); @@ -61,10 +78,8 @@ int erb_node_rmchild(struct erb_node *n, struct erb_node *c); int erb_node_addsurf(struct erb_node *n, struct erb_surf *s); int erb_node_rmsurf(struct erb_node *n, struct erb_surf *s); +/* sets the transformation matrix and also calculates the inverse */ void erb_node_setxform(struct erb_node *n, float *mat); -void erb_node_mulxform(struct erb_node *n, float *mat); -void erb_node_translate(struct erb_node *n, float x, float y, float z); -/* TODO ... more ... */ /* surfaces */ struct erb_surf *erb_surface(int datasz); @@ -73,6 +88,6 @@ struct erb_surf *erb_surf_sphere(float rad); struct erb_surf *erb_surf_box(float xsz, float ysz, float zsz); /* utility functions */ -void erb_xform_ray(struct erb_ray *ray, float *mat); +void erb_xform_ray(struct erb_ray *inray, float *mat, cgm_vec3 *org, cgm_vec3 *dir); #endif /* RENDLIB_H_ */