This commit is contained in:
2019-07-22 18:12:06 +02:00
parent db009a9ce5
commit 7d50d00ab6
7 changed files with 218 additions and 98 deletions

View File

@@ -1,5 +1,47 @@
use crate::vulkan::{Vertex, GameData};
use winit::{DeviceId, KeyboardInput, ElementState, VirtualKeyCode};
use std::time::SystemTime;
mod vulkan;
impl GameData<'_> {
fn on_init(self: &Self) {
}
fn on_keyboard_event(self: &Self, _: DeviceId, input: KeyboardInput) {
if input.state == ElementState::Pressed && input.virtual_keycode == Some(VirtualKeyCode::F) {
println!("doot");
}
}
fn update_push_constants(self: &mut Self) {
self.push_constants.time = self.start_time.elapsed().unwrap().as_millis() as f32 / 1000.0;
}
}
#[derive(Debug, Clone, Copy)]
pub struct PushConstants {
pub time: f32
}
fn main() {
vulkan::init();
let mut pc = PushConstants {
time: 0.0
};
let data = GameData {
mesh_vertices: vec![
Vertex { position: [0.1, 0.2, 0.2] },
Vertex { position: [0.2, 0.4, 0.2] },
Vertex { position: [0.2, 0.2, 0.3] }
],
line_vertices: vec![
Vertex { position: [-1., 0., 0.] },
Vertex { position: [1., 0., 0.] },
],
push_constants: &mut pc,
start_time: SystemTime::now()
};
vulkan::init(data);
}