Add debug in gui
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 10m16s

This commit is contained in:
Florian RICHER 2025-05-26 00:04:46 +02:00
parent c4c691c4dd
commit 1babc5bfeb
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
2 changed files with 19 additions and 8 deletions

View file

@ -14,9 +14,10 @@ use vulkano_util::window::{VulkanoWindows, WindowDescriptor};
use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use winit::event_loop::ActiveEventLoop;
use winit::keyboard::{KeyCode, PhysicalKey};
use winit::window::WindowId;
use super::input::InputState;
use super::input::{InputState, KeyState};
use super::vulkan_context::VulkanContext;
pub struct App {
@ -164,9 +165,24 @@ impl ApplicationHandler for App {
egui::Window::new("Informations")
.vscroll(true)
.show(&ctx, |ui| {
ui.label(format!("Format: {:?}", renderer.swapchain_format()));
ui.label(format!("Resolution: {:?}", renderer.resolution()));
ui.color_edit_button_rgb(&mut self.clear_color);
ui.label(format!(
"Mouse position: {:?}",
self.input_state.get_mouse_state().position
));
ui.label(format!(
"Mouse delta: {:?}",
self.input_state.get_mouse_state().delta
));
for (key, state) in
self.input_state.key_states.iter().filter(|(_, state)| {
*state == &KeyState::Pressed || *state == &KeyState::Held
})
{
ui.label(format!("{:?} State: {:?}", key, state));
}
});
});

View file

@ -6,7 +6,7 @@ use winit::{
keyboard::PhysicalKey,
};
#[derive(Debug, Default)]
#[derive(Debug, Default, PartialEq)]
pub enum KeyState {
#[default]
Pressed,
@ -74,11 +74,6 @@ impl InputState {
},
};
if let Some(new_key_state) = new_key_state {
log::trace!(
"New key state {:?} for key {:?}",
new_key_state,
event.physical_key
);
self.key_states.insert(key, new_key_state);
}
}