asdf
This commit is contained in:
28
src/main.rs
28
src/main.rs
@@ -1,6 +1,7 @@
|
||||
use crate::vulkan::{Vertex, GameData};
|
||||
use winit::{DeviceId, KeyboardInput, ElementState, VirtualKeyCode};
|
||||
use winit::{Event, WindowEvent};
|
||||
use std::time::SystemTime;
|
||||
use std::iter::FromIterator;
|
||||
|
||||
mod vulkan;
|
||||
|
||||
@@ -9,11 +10,26 @@ impl GameData<'_> {
|
||||
|
||||
}
|
||||
|
||||
fn on_keyboard_event(self: &Self, _: DeviceId, input: KeyboardInput) {
|
||||
if input.state == ElementState::Pressed && input.virtual_keycode == Some(VirtualKeyCode::F) {
|
||||
println!("doot");
|
||||
/// Returns true if event should be ignored by the vulkan handler
|
||||
fn on_window_event(self: &Self, event: &Event) -> bool {
|
||||
match event {
|
||||
Event::WindowEvent { event: WindowEvent::KeyboardInput { device_id, input }, .. } => {
|
||||
let mods = String::from_iter(
|
||||
vec!["shift", "ctrl", "alt", "logo"].iter()
|
||||
.zip(vec![input.modifiers.shift, input.modifiers.ctrl, input.modifiers.alt, input.modifiers.logo])
|
||||
.filter(|(&_name, state)| *state)
|
||||
.map(|(&name, _state)| name));
|
||||
if mods.len() > 0 {
|
||||
println!("Keyboard {:?} input {:?} {:?} + {:?}", device_id, input.state, &mods, input.scancode)
|
||||
} else {
|
||||
println!("Keyboard {:?} input {:?} {:?}", device_id, input.state, input.scancode)
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
fn update_push_constants(self: &mut Self) {
|
||||
self.push_constants.time = self.start_time.elapsed().unwrap().as_millis() as f32 / 1000.0;
|
||||
}
|
||||
@@ -36,8 +52,8 @@ fn main() {
|
||||
Vertex { position: [0.2, 0.2, 0.3] }
|
||||
],
|
||||
line_vertices: vec![
|
||||
Vertex { position: [-1., 0., 0.] },
|
||||
Vertex { position: [1., 0., 0.] },
|
||||
Vertex { position: [-0.9, 1., 0.] },
|
||||
Vertex { position: [0.9, 0., 0.] },
|
||||
],
|
||||
push_constants: &mut pc,
|
||||
start_time: SystemTime::now()
|
||||
|
||||
Reference in New Issue
Block a user