From 8d74443e178b6c4cb5af28aef60d2db3d2d76edf Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Wed, 5 Jul 2023 14:34:24 +0100 Subject: [PATCH] Display more realtime framerate in title --- src/core/app.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/app.rs b/src/core/app.rs index 535cab0..ec01ee3 100644 --- a/src/core/app.rs +++ b/src/core/app.rs @@ -12,6 +12,7 @@ use crate::{ }; pub struct App { + title: String, window: winit::window::Window, event_loop: EventLoop<()>, render_ctx: render::Context, @@ -39,6 +40,7 @@ impl App { .await; Self { + title: title.to_owned(), window, event_loop, render_ctx, @@ -109,6 +111,11 @@ impl App { renderer.update_brickmap(&self.render_ctx, &mut world); // Simple framerate tracking + self.window.set_title(&format!( + "{}: {} fps", + self.title, + (1.0 / dt.as_secs_f32()).floor() + )); cumulative_dt += dt.as_secs_f32(); frames_accumulated += 1.0; if cumulative_dt >= 1.0 {