Skip to content

Commit 06fbd38

Browse files
author
Peter Aarestad
committed
move status printing into render_frame
1 parent 047691a commit 06fbd38

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn main() -> anyhow::Result<()> {
6565
.expect("standalone render should not be cancelled");
6666

6767
let mut image = RgbImage::new(world.image_width, world.image_height);
68+
6869
for (flipped_y, row) in &rows {
6970
for (x, pixel_color) in row.iter().enumerate() {
7071
image.put_pixel(
@@ -73,7 +74,6 @@ fn main() -> anyhow::Result<()> {
7374
pixel_color.to_image_rgbu8(world.samples_per_pixel),
7475
);
7576
}
76-
println!("{} / {} scanlines done", image.height() - flipped_y, world.image_height);
7777
}
7878

7979
ImageRgb8(image).save("output.png")?;

src/util/render.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,14 @@ pub fn render_frame(
101101
drop(tx);
102102

103103
let mut rows = Vec::with_capacity(render_h as usize);
104-
for item in rx.iter() {
104+
for (idx, row) in rx.iter().enumerate() {
105105
if let Some((ref generation, expected)) = cancel
106106
&& generation.load(Ordering::Acquire) != expected
107107
{
108108
return None;
109109
}
110-
rows.push(item);
110+
rows.push(row);
111+
println!("{} / {} scanlines done", idx, world.image_height);
111112
}
112113

113114
if cancel.is_none_or(|(generation, expected)| generation.load(Ordering::Acquire) == expected) {

0 commit comments

Comments
 (0)