Create scene data structure

This commit is contained in:
2025-09-23 15:36:08 +01:00
parent a6b52d5f75
commit 61f9ec7642
4 changed files with 34 additions and 20 deletions

12
demo.c
View File

@@ -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);