Display more realtime framerate in title
This commit is contained in:
parent
9d4223a1cc
commit
8d74443e17
|
@ -12,6 +12,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
|
title: String,
|
||||||
window: winit::window::Window,
|
window: winit::window::Window,
|
||||||
event_loop: EventLoop<()>,
|
event_loop: EventLoop<()>,
|
||||||
render_ctx: render::Context,
|
render_ctx: render::Context,
|
||||||
|
@ -39,6 +40,7 @@ impl App {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
title: title.to_owned(),
|
||||||
window,
|
window,
|
||||||
event_loop,
|
event_loop,
|
||||||
render_ctx,
|
render_ctx,
|
||||||
|
@ -109,6 +111,11 @@ impl App {
|
||||||
renderer.update_brickmap(&self.render_ctx, &mut world);
|
renderer.update_brickmap(&self.render_ctx, &mut world);
|
||||||
|
|
||||||
// Simple framerate tracking
|
// Simple framerate tracking
|
||||||
|
self.window.set_title(&format!(
|
||||||
|
"{}: {} fps",
|
||||||
|
self.title,
|
||||||
|
(1.0 / dt.as_secs_f32()).floor()
|
||||||
|
));
|
||||||
cumulative_dt += dt.as_secs_f32();
|
cumulative_dt += dt.as_secs_f32();
|
||||||
frames_accumulated += 1.0;
|
frames_accumulated += 1.0;
|
||||||
if cumulative_dt >= 1.0 {
|
if cumulative_dt >= 1.0 {
|
||||||
|
|
Loading…
Reference in New Issue