/* Main command line executable. */ #include #define STB_IMAGE_WRITE_IMPLEMENTATION #include int main(int argc, char **argv) { df_sphere spheres[2]; spheres[0].center_x = 0.f; spheres[0].center_y = 0.f; spheres[0].center_z = -1.f; spheres[0].radius = .5f; spheres[1].center_x = 0.25f; spheres[1].center_y = 0.25f; spheres[1].center_z = -1.5f; spheres[1].radius = .75f; int image_width = 1024; int image_height = 512; df_image_handle input_image = df_load_image("../test_image.png", &image_width, &image_height); float aspect = (float)image_width / (float)image_height; df_plane plane; plane.base_x = 0.f; plane.base_y = 0.f; plane.base_z = -1.f; plane.normal_x = 0.f; plane.normal_y = 0.f; plane.normal_z = 1.f; plane.img_p0_x = -aspect; plane.img_p0_y = -1.f; plane.img_p0_z = plane.base_z; plane.img_w = 2.f * aspect; plane.img_h = 2.f; plane.img_ax0_x = 1.f; plane.img_ax0_y = 0.f; plane.img_ax0_z = 0.f; plane.img_ax1_x = 0.f; plane.img_ax1_y = 1.f; plane.img_ax1_z = 0.f; plane.image = input_image; uint8_t *image = NULL; df_trace_rays((df_trace_rays_settings){ .focal_length = 1.f, .image_width = image_width, .image_height = image_height, }, spheres, 0, &plane, 1, &image); stbi_write_png("raytracer.png", image_width, image_height, 3, image, image_width * 3); return 0; }