eoc7: make command flag for choosing rendering strategy.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bill Thiede 2021-07-18 11:49:56 -07:00
parent 4f88d2c101
commit dbf5451070

View File

@ -1,9 +1,10 @@
use std::{f32::consts::PI, time::Instant};
use anyhow::Result;
use structopt::StructOpt;
use rtchallenge::{
camera::Camera,
camera::{Camera, RenderStrategy},
lights::PointLight,
materials::Material,
matrices::Matrix4x4,
@ -14,8 +15,17 @@ use rtchallenge::{
WHITE,
};
/// End of chapter 7 challenge.
#[derive(StructOpt, Debug)]
#[structopt(name = "eoc7")]
struct Opt {
#[structopt(long, default_value = "rayon")]
render_strategy: RenderStrategy,
}
fn main() -> Result<()> {
let start = Instant::now();
let opt = Opt::from_args();
let width = 1024;
let height = 1024;
let light_position = Tuple::point(-10., 10., -10.);
@ -26,6 +36,7 @@ fn main() -> Result<()> {
let to = Tuple::point(0., 1., 0.);
let up = Tuple::point(0., 1., 0.);
camera.set_transform(view_transform(from, to, up));
camera.render_strategy = opt.render_strategy;
let mut floor = Sphere::default();
floor.set_transform(Matrix4x4::scaling(10., 0.01, 10.));