aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: 4abc7c91213c8bd775af24cf0bd0b2566bf5bef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use cgmath::vec3;
use rand::prelude::*;

mod camera;
mod colour;
mod hittable;
mod material;
mod random;
mod ray;
mod render;
mod scene;
mod sphere;

fn main() {
    let image_width = 200;
    let image_height = 100;
    let samples = 50;
    let max_depth = 25;

    println!("P3\n{} {}\n255", image_width, image_height);

    let mut world = scene::Scene::new();
    world.add(Box::new(sphere::Sphere::new(
        vec3(0.0, 0.0, -1.0), 0.5, Box::new(material::Lambertian::new(vec3(1.0, 1.0, 1.0))))));
    world.add(Box::new(sphere::Sphere::new(
        vec3(0.0, -100.5, -1.0), 100.0, Box::new(material::Lambertian::new(vec3(1.0, 1.0, 1.0))))));

    let camera = camera::Camera::new();

    let mut rng = thread_rng();

    render::render(&world, camera, image_height, image_width, samples, max_depth, &mut rng);

    eprintln!("\nDone")
}