executable: add scene parsing and rendering

This commit is contained in:
Bruno BELANYI 2020-03-18 16:32:55 +01:00
parent e383b77f68
commit f066ea7125

View file

@ -1,3 +1,24 @@
fn main() {
println!("Hello, world!");
use pathtracer::render::Scene;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Options {
/// Input description for the scene to be rendered.
#[structopt(short, long, parse(from_os_str), default_value = "scene.yaml")]
input: PathBuf,
/// Output image for the rendered scene.
#[structopt(short, long, parse(from_os_str), default_value = "scene.png")]
output: PathBuf,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let options = Options::from_args();
let f = std::fs::File::open(options.input)?;
let scene: Scene = serde_yaml::from_reader(f)?;
let image = scene.render();
image.save(options.output)?;
Ok(())
}