Move Opt from library to CLI.
This commit is contained in:
parent
23058d1268
commit
9bd29660ff
@ -1,7 +1,9 @@
|
||||
extern crate rand;
|
||||
extern crate rtiow;
|
||||
#[macro_use]
|
||||
extern crate structopt;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::time::Instant;
|
||||
|
||||
use rand::Rng;
|
||||
@ -14,7 +16,6 @@ use rtiow::material::Dielectric;
|
||||
use rtiow::material::Lambertian;
|
||||
use rtiow::material::Metal;
|
||||
use rtiow::renderer::render;
|
||||
use rtiow::renderer::Opt;
|
||||
use rtiow::renderer::Scene;
|
||||
use rtiow::sphere::Sphere;
|
||||
use rtiow::vec3::Vec3;
|
||||
@ -159,6 +160,24 @@ fn build_scene(opt: &Opt) -> Scene {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "tracert", about = "An experimental ray tracer.")]
|
||||
pub struct Opt {
|
||||
/// Image width
|
||||
#[structopt(short = "w", long = "width", default_value = "1280")]
|
||||
pub width: usize,
|
||||
/// Image height
|
||||
#[structopt(short = "h", long = "height", default_value = "720")]
|
||||
pub height: usize,
|
||||
/// Sub-samples per pixel
|
||||
#[structopt(short = "s", long = "subsample", default_value = "10")]
|
||||
pub subsamples: usize,
|
||||
|
||||
/// Output file
|
||||
#[structopt(parse(from_os_str))]
|
||||
pub output: PathBuf,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
let start = Instant::now();
|
||||
let opt = Opt::from_args();
|
||||
|
||||
@ -10,5 +10,3 @@ pub mod vec3;
|
||||
extern crate image;
|
||||
extern crate rand;
|
||||
extern crate rayon;
|
||||
#[macro_use]
|
||||
extern crate structopt;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use std;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use image;
|
||||
use image::RgbImage;
|
||||
@ -13,24 +12,6 @@ use hitable_list::HitableList;
|
||||
use ray::Ray;
|
||||
use vec3::Vec3;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "tracert", about = "An experimental ray tracer.")]
|
||||
pub struct Opt {
|
||||
/// Image width
|
||||
#[structopt(short = "w", long = "width", default_value = "1280")]
|
||||
pub width: usize,
|
||||
/// Image height
|
||||
#[structopt(short = "h", long = "height", default_value = "720")]
|
||||
pub height: usize,
|
||||
/// Sub-samples per pixel
|
||||
#[structopt(short = "s", long = "subsample", default_value = "10")]
|
||||
pub subsamples: usize,
|
||||
|
||||
/// Output file
|
||||
#[structopt(parse(from_os_str))]
|
||||
pub output: PathBuf,
|
||||
}
|
||||
|
||||
pub struct Scene {
|
||||
pub world: HitableList,
|
||||
pub camera: Camera,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user