--- a/rust/hwrunner/src/main.rs Sun Nov 15 05:35:18 2020 +0300
+++ b/rust/hwrunner/src/main.rs Mon Nov 16 01:41:42 2020 +0300
@@ -50,8 +50,11 @@
let mut now = Instant::now();
let mut update = Instant::now();
+ let mut render = Instant::now();
+ unsafe { window.make_current().unwrap() };
let mut is_running = true;
+
while is_running {
let curr = Instant::now();
let delta = curr - now;
@@ -100,9 +103,10 @@
_ => (),
});
- unsafe { window.make_current().unwrap() };
-
- engine.render();
- window.swap_buffers().unwrap();
+ if render.elapsed() > Duration::from_millis(16) {
+ render = curr;
+ engine.render();
+ window.swap_buffers().unwrap();
+ }
}
}