|
|
@ -65,6 +65,10 @@ pub struct PersistentState {
|
|
|
|
compu_frame: CompuFrame,
|
|
|
|
compu_frame: CompuFrame,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct TrSprite {
|
|
|
|
|
|
|
|
entity: Entity,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
pub fn main() {
|
|
|
|
//hprof::start_frame();
|
|
|
|
//hprof::start_frame();
|
|
|
|
//let g = hprof::enter("vulkan preload");
|
|
|
|
//let g = hprof::enter("vulkan preload");
|
|
|
@ -150,7 +154,7 @@ pub fn main() {
|
|
|
|
.with(Images { images: vec![compu_image], image_resolutions: vec![image_dimensions_u] })
|
|
|
|
.with(Images { images: vec![compu_image], image_resolutions: vec![image_dimensions_u] })
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
world.create_entity()
|
|
|
|
let sprite = world.create_entity()
|
|
|
|
.with(Evented { subscribed: |event| {true} })
|
|
|
|
.with(Evented { subscribed: |event| {true} })
|
|
|
|
.with(Position { x: 0.0, y: 0.0, z: 0 })
|
|
|
|
.with(Position { x: 0.0, y: 0.0, z: 0 })
|
|
|
|
.with(Geometry { size_x: 300.0, size_y: 300.0, rotation: 0.0 })
|
|
|
|
.with(Geometry { size_x: 300.0, size_y: 300.0, rotation: 0.0 })
|
|
|
@ -203,7 +207,7 @@ pub fn main() {
|
|
|
|
events_loop.run(move |event, _, control_flow| {
|
|
|
|
events_loop.run(move |event, _, control_flow| {
|
|
|
|
*control_flow = ControlFlow::Poll;
|
|
|
|
*control_flow = ControlFlow::Poll;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The incoming event type will indicate what section of the event loop we are in
|
|
|
|
match event {
|
|
|
|
match event {
|
|
|
|
Event::NewEvents(cause) => {
|
|
|
|
Event::NewEvents(cause) => {
|
|
|
|
if cause == StartCause::Init {
|
|
|
|
if cause == StartCause::Init {
|
|
|
@ -240,6 +244,8 @@ pub fn main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
accumulator_time += delta_time;
|
|
|
|
accumulator_time += delta_time;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
world.
|
|
|
|
|
|
|
|
|
|
|
|
// This dispatches all the systems in parallel (but blocking).
|
|
|
|
// This dispatches all the systems in parallel (but blocking).
|
|
|
|
world.write_resource::<PersistentState>()
|
|
|
|
world.write_resource::<PersistentState>()
|
|
|
|
.delta_time = delta_time;
|
|
|
|
.delta_time = delta_time;
|
|
|
@ -251,55 +257,56 @@ pub fn main() {
|
|
|
|
_ => {}
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Each NewEvents event will clear this event stack
|
|
|
|
world.write_resource::<Vec<TrEvent<TrEventExtension>>>().push(event.into());
|
|
|
|
world.write_resource::<Vec<TrEvent<TrEventExtension>>>().push(event.into());
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
/*
|
|
|
|
// match event {
|
|
|
|
match event {
|
|
|
|
|
|
|
|
|
|
|
|
// Event::UserEvent(TrEventExtension::KeyHeldEvent {}) => {}
|
|
|
|
|
|
|
|
// Event::UserEvent(TrEventExtension::MouseHeldEvent {}) => {}
|
|
|
|
|
|
|
|
// Event::UserEvent(TrEventExtension::GamepadEvent { gil_event }) => {}
|
|
|
|
|
|
|
|
// Event::DeviceEvent { device_id, event } => {
|
|
|
|
|
|
|
|
// match event {
|
|
|
|
|
|
|
|
// DeviceEvent::Key(keyboard_input) => {
|
|
|
|
|
|
|
|
// match keyboard_input.virtual_keycode.unwrap() {
|
|
|
|
|
|
|
|
// VirtualKeyCode::A => {
|
|
|
|
|
|
|
|
// if keyboard_input.state == ElementState::Pressed {}
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// VirtualKeyCode::S => {
|
|
|
|
|
|
|
|
// if keyboard_input.state == ElementState::Pressed {}
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// VirtualKeyCode::P => {
|
|
|
|
|
|
|
|
// if keyboard_input.state == ElementState::Pressed {
|
|
|
|
|
|
|
|
// let data = world.write_resource::<VkProcessor>().read_compute_buffer(compute_buffer.clone());
|
|
|
|
|
|
|
|
// image::save_buffer(&Path::new("image.png"), data.as_slice(), (image_data.1).0, (image_data.1).1, image::RGBA(8));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// _ => ()
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// _ => {}
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// _ => ()
|
|
|
|
Event::UserEvent(TrEventExtension::KeyHeldEvent {}) => {}
|
|
|
|
// }
|
|
|
|
Event::UserEvent(TrEventExtension::MouseHeldEvent {}) => {}
|
|
|
|
|
|
|
|
Event::UserEvent(TrEventExtension::GamepadEvent { gil_event }) => {}
|
|
|
|
|
|
|
|
Event::DeviceEvent { device_id, event } => {
|
|
|
|
|
|
|
|
match event {
|
|
|
|
|
|
|
|
DeviceEvent::Key(keyboard_input) => {
|
|
|
|
|
|
|
|
match keyboard_input.virtual_keycode.unwrap() {
|
|
|
|
|
|
|
|
VirtualKeyCode::A => {
|
|
|
|
|
|
|
|
if keyboard_input.state == ElementState::Pressed {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
VirtualKeyCode::S => {
|
|
|
|
|
|
|
|
if keyboard_input.state == ElementState::Pressed {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
VirtualKeyCode::P => {
|
|
|
|
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
|
|
|
|
let data = world.write_resource::<VkProcessor>().read_compute_buffer(compute_buffer.clone());
|
|
|
|
|
|
|
|
image::save_buffer(&Path::new("image.png"), data.as_slice(), (image_data.1).0, (image_data.1).1, image::RGBA(8));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_ => ()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// bucket the events out, but not really
|
|
|
|
|
|
|
|
// match
|
|
|
|
_ => ()
|
|
|
|
// event {
|
|
|
|
}
|
|
|
|
// Event::NewEvents(_) => {}
|
|
|
|
|
|
|
|
// Event::WindowEvent { window_id, event } => {}
|
|
|
|
bucket the events out, but not really
|
|
|
|
// Event::DeviceEvent { device_id, event } => {}
|
|
|
|
match
|
|
|
|
// Event::UserEvent(tr_event) => {}
|
|
|
|
event {
|
|
|
|
// Event::Suspended => {}
|
|
|
|
Event::NewEvents(_) => {}
|
|
|
|
// Event::Resumed => {}
|
|
|
|
Event::WindowEvent { window_id, event } => {}
|
|
|
|
// Event::MainEventsCleared => {}
|
|
|
|
Event::DeviceEvent { device_id, event } => {}
|
|
|
|
// Event::RedrawRequested(_) => {}
|
|
|
|
Event::UserEvent(tr_event) => {}
|
|
|
|
// Event::RedrawEventsCleared => {}
|
|
|
|
Event::Suspended => {}
|
|
|
|
// Event::LoopDestroyed => {}
|
|
|
|
Event::Resumed => {}
|
|
|
|
// }
|
|
|
|
Event::MainEventsCleared => {}
|
|
|
|
|
|
|
|
Event::RedrawRequested(_) => {}
|
|
|
|
|
|
|
|
Event::RedrawEventsCleared => {}
|
|
|
|
|
|
|
|
Event::LoopDestroyed => {}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|