summaryrefslogtreecommitdiff
path: root/alligator_render/examples/bunnymark.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alligator_render/examples/bunnymark.rs')
-rw-r--r--alligator_render/examples/bunnymark.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/alligator_render/examples/bunnymark.rs b/alligator_render/examples/bunnymark.rs
index 62371c9..4fe37d3 100644
--- a/alligator_render/examples/bunnymark.rs
+++ b/alligator_render/examples/bunnymark.rs
@@ -4,11 +4,26 @@ use alligator_render::{
ImageFormat, Instance, InstanceId, RenderWindowConfig, Renderer, TextureId,
};
+fn xorshift_plus(seed: &mut [u64; 2]) -> u64 {
+ let mut t = seed[0];
+ let s = seed[1];
+
+ t ^= t << 23;
+ t ^= t >> 18;
+ t ^= s ^ (s >> 5);
+
+ seed[0] = s;
+ seed[1] = t;
+
+ t + s
+}
+
#[derive(Debug)]
struct State {
texture_id: TextureId,
bunnies: Vec<Bunny>,
previous_timestamp: Option<Instant>,
+ seed: [u64; 2],
stopped: bool,
}
@@ -18,6 +33,7 @@ impl State {
texture_id,
bunnies: Vec::with_capacity(10_000_000),
previous_timestamp: None,
+ seed: [0x0D15EA5E8BADF00D, 0xDECAFBADDEADBEAF],
stopped: false,
}
}
@@ -78,13 +94,13 @@ impl State {
let instance_id = renderer.instances_mut().push_instance(Instance {
texture_coordinates: [texture_x, texture_y],
texture_size: [texture_width, texture_height],
- size: [0.1, 0.1],
+ size: [0.08, 0.08],
position: [-1.5, 0.70],
..Default::default()
});
- let velocity_x = fps.fract() / 24.0;
- let velocity_y = 0.0;
+ let velocity_x = (xorshift_plus(&mut self.seed) % 1_000_000) as f32 / 25_000_000.0;
+ let velocity_y = (xorshift_plus(&mut self.seed) % 1_000_000) as f32 / 25_000_000.0;
self.bunnies.push(Bunny {
instance_id,
velocity_x,