projects
/
mandelwow.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
23b8979
)
Add FPS counter.
author
Bernie Innocenti
<bernie@codewiz.org>
Mon, 8 May 2017 00:33:35 +0000
(20:33 -0400)
committer
Bernie Innocenti
<bernie@codewiz.org>
Mon, 8 May 2017 00:33:35 +0000
(20:33 -0400)
main.rs
patch
|
blob
|
history
diff --git
a/main.rs
b/main.rs
index 37fc5a50afb2a01dbc4692a6401dc1997f57938a..b492676cfb51527ce537c9c86679b735a44101af 100644
(file)
--- a/
main.rs
+++ b/
main.rs
@@
-14,6
+14,7
@@
use glutin::Event::KeyboardInput;
use glutin::VirtualKeyCode;
use mandelwow_lib::*;
use std::f32::consts::PI;
use glutin::VirtualKeyCode;
use mandelwow_lib::*;
use std::f32::consts::PI;
+use std::time::{Duration, Instant};
#[cfg(target_os = "emscripten")]
use std::os::raw::{c_int, c_void};
#[cfg(target_os = "emscripten")]
use std::os::raw::{c_int, c_void};
@@
-125,6
+126,10
@@
fn main() {
}
}
}
}
+ let mut frame_cnt = 0;
+ let mut last_report_time = Instant::now();
+ let mut last_report_frame_cnt = 0;
+
set_main_loop_callback(|| {
camera.update();
let perspview = camera.get_perspview();
set_main_loop_callback(|| {
camera.update();
let perspview = camera.get_perspview();
@@
-218,6
+223,16
@@
fn main() {
}
}
}
}
+ frame_cnt += 1;
+ let now = Instant::now();
+ if now - last_report_time > Duration::from_secs(10) {
+ let fps = (frame_cnt - last_report_frame_cnt) as f32 /
+ (now - last_report_time).as_secs() as f32;
+ println!("fps={}", fps);
+ last_report_time = now;
+ last_report_frame_cnt = frame_cnt;
+ }
+
support::Action::Continue
});
}
support::Action::Continue
});
}