diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 7ec82e6..c99ca58 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ mod material; mod ray; mod util; mod vec3; -mod image; +mod display; mod texture; mod scenes; @@ -12,7 +12,7 @@ use std::{sync::{Arc, mpsc}, thread}; use camera::Camera; use hittable::Hittable; -use image::Image; +use display::{Display, Image, Pixelflut}; use ray::Ray; use vec3::{Vec3, Color}; use scenes::get_scene; @@ -70,7 +70,7 @@ fn main() { //const ASPECT_RATIO: f64 = 1.0; const IMAGE_WIDTH: u32 = 600; const IMAGE_HEIGHT: u32 = (IMAGE_WIDTH as f64 / ASPECT_RATIO) as u32; - const SAMPLES_PER_PIXEL: u32 = 30; + const SAMPLES_PER_PIXEL: u32 = 500; const MAX_DEPTH: u32 = 50; const THREAD_COUNT: u32 = 8; const TIME_START: f64 = 0.0; @@ -83,7 +83,8 @@ fn main() { let dist_to_focus = 10.0; let cam = Arc::new(Camera::new(lookfrom, lookat, vup, vfov, ASPECT_RATIO, aperture, dist_to_focus, TIME_START, TIME_END)); // Render - let mut final_image = Image::new(IMAGE_WIDTH as usize, IMAGE_HEIGHT as usize); + // let mut final_image = Image::new(IMAGE_WIDTH as usize, IMAGE_HEIGHT as usize); + let mut final_image = Pixelflut::new("192.168.0.38:1337", 0, 0, IMAGE_WIDTH as usize, IMAGE_HEIGHT as usize); let (tx, rx) = mpsc::channel::<PixelUpdate>(); for _ in 0..THREAD_COUNT { let sender = tx.clone(); @@ -96,12 +97,14 @@ fn main() { } let expected_updates: u64 = (SAMPLES_PER_PIXEL / THREAD_COUNT) as u64 * THREAD_COUNT as u64 * IMAGE_HEIGHT as u64 * IMAGE_WIDTH as u64; let print_frequency: u64 = (SAMPLES_PER_PIXEL / THREAD_COUNT) as u64 * THREAD_COUNT as u64 * IMAGE_WIDTH as u64; + let print_frequency = print_frequency * 3; let mut update_count: u64 = 0; loop { if let Ok(update) = rx.try_recv() { update_count += 1; final_image.add_sample(update.x, update.y, update.color); if update_count % print_frequency == 0 { + final_image.maybe_update(); eprint!("\rCurrent completion: {:.2}%", (update_count as f64 / expected_updates as f64) * 100.0) } } else { @@ -110,6 +113,7 @@ fn main() { } } } - final_image.write(&mut std::io::stdout()); + final_image.maybe_update(); + final_image.maybe_write(&mut std::io::stdout()); eprintln!("\nDone."); } |