Separate timing of rendering and image writing in print out.
This commit is contained in:
parent
cf49cdbb02
commit
c997c55739
|
@ -44,6 +44,7 @@ use std::mem;
|
|||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
|
||||
use docopt::Docopt;
|
||||
|
||||
|
@ -146,8 +147,12 @@ fn main() {
|
|||
println!("\tBuilt scene in {:.3}s", t.tick());
|
||||
|
||||
println!("Rendering scene with {} threads...", thread_count);
|
||||
r.render(thread_count);
|
||||
let mut image = r.render(thread_count);
|
||||
println!("\tRendered scene in {:.3}s", t.tick());
|
||||
|
||||
println!("Writing image to disk...");
|
||||
let _ = image.write_png(Path::new(&r.output_file));
|
||||
println!("\tWrote image in {:.3}s", t.tick());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::cmp;
|
||||
use std::io::{self, Write};
|
||||
use std::path::Path;
|
||||
use std::cmp::min;
|
||||
use std::cell::Cell;
|
||||
use std::sync::{RwLock, Mutex};
|
||||
|
@ -29,10 +28,10 @@ pub struct Renderer {
|
|||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn render(&self, thread_count: u32) {
|
||||
pub fn render(&self, thread_count: u32) -> Image {
|
||||
let mut tpool = Pool::new(thread_count);
|
||||
|
||||
let mut image = Image::new(self.resolution.0, self.resolution.1);
|
||||
let image = Image::new(self.resolution.0, self.resolution.1);
|
||||
let (img_width, img_height) = (image.width(), image.height());
|
||||
|
||||
let all_jobs_queued = RwLock::new(false);
|
||||
|
@ -215,12 +214,11 @@ impl Renderer {
|
|||
*all_jobs_queued.write().unwrap() = true;
|
||||
});
|
||||
|
||||
|
||||
// Write rendered image to disk
|
||||
let _ = image.write_png(Path::new(&self.output_file));
|
||||
|
||||
// Clear percentage progress print
|
||||
print!("\r \r");
|
||||
|
||||
// Return the rendered image
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user