v0.1 working
This commit is contained in:
@@ -31,6 +31,9 @@ struct PrometeuApp {
|
||||
|
||||
frame_target_dt: Duration,
|
||||
next_frame: Instant,
|
||||
|
||||
last_stats_update: Instant,
|
||||
frames_since_last_update: u64,
|
||||
}
|
||||
|
||||
impl PrometeuApp {
|
||||
@@ -45,6 +48,9 @@ impl PrometeuApp {
|
||||
|
||||
frame_target_dt: Duration::from_nanos(1_000_000_000 / 60),
|
||||
next_frame: Instant::now(),
|
||||
|
||||
last_stats_update: Instant::now(),
|
||||
frames_since_last_update: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +78,7 @@ impl PrometeuApp {
|
||||
impl ApplicationHandler for PrometeuApp {
|
||||
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||
let attrs = WindowAttributes::default()
|
||||
.with_title(format!("PROMETEU - host_desktop | GFX Mem: {:.2} KB | Frame: {}", 0.0, 0))
|
||||
.with_title(format!("PROMETEU | GFX: {:.1} KB | FPS: {:.1} | Frame: {}", 0.0, 0.0, 0))
|
||||
.with_inner_size(LogicalSize::new(960.0, 540.0))
|
||||
.with_min_inner_size(LogicalSize::new(320.0, 180.0));
|
||||
|
||||
@@ -188,18 +194,25 @@ impl ApplicationHandler for PrometeuApp {
|
||||
// executa 1 frame do PROMETEU
|
||||
self.machine.step_frame(&self.input_signals);
|
||||
|
||||
// temp: atualiza o título da janela a cada 1 segundo (60 frames)
|
||||
if self.machine.frame_index % 60 == 0 {
|
||||
self.frames_since_last_update += 1;
|
||||
|
||||
let elapsed = now.duration_since(self.last_stats_update);
|
||||
if elapsed >= Duration::from_secs(1) {
|
||||
if let Some(window) = self.window {
|
||||
let fps = self.frames_since_last_update as f64 / elapsed.as_secs_f64();
|
||||
let usage_bytes = self.machine.gfx.memory_usage_bytes();
|
||||
let kb = usage_bytes as f64 / 1024.0;
|
||||
|
||||
let title = format!(
|
||||
"PROMETEU - host_desktop | GFX Mem: {:.2} KB | Frame: {}",
|
||||
"PROMETEU | GFX: {:.1} KB | FPS: {:.1} | Frame: {}",
|
||||
kb,
|
||||
fps,
|
||||
self.machine.frame_index);
|
||||
window.set_title(&title);
|
||||
}
|
||||
|
||||
self.last_stats_update = now;
|
||||
self.frames_since_last_update = 0;
|
||||
}
|
||||
|
||||
// pede redraw
|
||||
|
||||
Reference in New Issue
Block a user