Skip to content

Commit 11edefd

Browse files
committed
Using incrementing numbers instead of random values as filenames
1 parent e5d805a commit 11edefd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

examples/app/headless_renderer.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn setup(
9191
&mut images,
9292
&render_device,
9393
&mut scene_controller,
94-
// pre_roll_frames should be big enought for full scene render,
94+
// pre_roll_frames should be big enough for full scene render,
9595
// but the bigger it is, the longer example will run.
9696
// To visualize stages of scene rendering change this param to 0
9797
// and change AppConfig::single_image to false in main
@@ -100,7 +100,7 @@ fn setup(
100100
// 2. Few black box images
101101
// 3. Fully rendered scene images
102102
// Exact number depends on device speed, device load and scene size
103-
30,
103+
40,
104104
"main_scene".into(),
105105
);
106106

@@ -499,9 +499,6 @@ mod frame_capture {
499499
) {
500500
if let SceneState::Render(n) = scene_controller.state {
501501
if n < 1 {
502-
use rand::Rng;
503-
let mut rng = rand::thread_rng();
504-
505502
// We don't want to block the main world on this,
506503
// so we use try_recv which attempts to receive without blocking
507504
let mut image_data = Vec::new();
@@ -525,8 +522,12 @@ mod frame_capture {
525522
info!("Saving image to: {images_dir:?}");
526523
std::fs::create_dir_all(&images_dir).unwrap();
527524

528-
let number = rng.gen::<u128>();
529-
let image_path = images_dir.join(format!("{number:032X}.png"));
525+
let mut number = 0;
526+
let mut image_path = images_dir.join(format!("{number:03}.png"));
527+
while image_path.exists() {
528+
number += 1;
529+
image_path = images_dir.join(format!("{number:03}.png"))
530+
}
530531
if let Err(e) = img.save(image_path) {
531532
panic!("Failed to save image: {}", e);
532533
};

0 commit comments

Comments
 (0)