Create scene data structure
This commit is contained in:
12
demo.c
12
demo.c
@@ -15,7 +15,9 @@
|
||||
static const vec3_t camera_pos = { 0.0, 1.5, -2.0 };
|
||||
static const vec3_t camera_target = { 0.0, 1.0, 1.0 };
|
||||
|
||||
static const obj_t scene[] = {
|
||||
static const vec3_t sky = { 0.6, 0.7, 1.0 };
|
||||
|
||||
static const obj_t objs[] = {
|
||||
SPHERE(1.0, 1.0, 3.0, 1.0, LAMBERTIAN(0.6, 0.2, 0.8)),
|
||||
SPHERE(-0.8, 1.0, 3.8, 1.0, LAMBERTIAN(1.0, 1.0, 1.0)),
|
||||
SPHERE(-1.0, 0.2, 2.6, 0.2, LAMBERTIAN(0.2, 0.9, 0.3)),
|
||||
@@ -30,10 +32,16 @@ static pix_t pixbuf[W * H];
|
||||
|
||||
int main()
|
||||
{
|
||||
const scene_t scene = {
|
||||
.sky_colour = sky,
|
||||
.objs = objs,
|
||||
.obj_count = NELEMS(objs),
|
||||
};
|
||||
|
||||
img_t img = { .pix = pixbuf };
|
||||
camera_t camera = camera_init(
|
||||
camera_pos, camera_target, FOV, W, H, SAMPLES_PER_PIXEL);
|
||||
camera_render(&camera, scene, NELEMS(scene), &img);
|
||||
camera_render(&camera, &scene, &img);
|
||||
|
||||
ff_write(STDOUT_FILENO, img);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user