|
|
@ -10,20 +10,24 @@ extern crate nalgebra as na;
|
|
|
|
extern crate rand;
|
|
|
|
extern crate rand;
|
|
|
|
extern crate time;
|
|
|
|
extern crate time;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use std::path::Path;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use gilrs::{Button, Event as GilEvent, Gamepad, GamepadId, Gilrs};
|
|
|
|
use vulkano::instance::debug::DebugCallback;
|
|
|
|
use vulkano::instance::debug::DebugCallback;
|
|
|
|
use vulkano::instance::Instance;
|
|
|
|
use vulkano::instance::Instance;
|
|
|
|
use vulkano::sync;
|
|
|
|
use vulkano::sync;
|
|
|
|
use vulkano::sync::GpuFuture;
|
|
|
|
use vulkano::sync::GpuFuture;
|
|
|
|
use vulkano_win::VkSurfaceBuild;
|
|
|
|
use vulkano_win::VkSurfaceBuild;
|
|
|
|
use winit::dpi::LogicalSize;
|
|
|
|
use winit::dpi::LogicalSize;
|
|
|
|
use winit::event::{DeviceEvent, ElementState, Event, VirtualKeyCode, WindowEvent, MouseButton};
|
|
|
|
use winit::event::{DeviceEvent, ElementState, Event, MouseButton, VirtualKeyCode, WindowEvent};
|
|
|
|
use winit::event_loop::{EventLoop, ControlFlow, EventLoopProxy};
|
|
|
|
use winit::event_loop::{ControlFlow, EventLoop, EventLoopProxy};
|
|
|
|
use winit::platform::unix::WindowBuilderExtUnix;
|
|
|
|
use winit::platform::unix::WindowBuilderExtUnix;
|
|
|
|
use winit::window::WindowBuilder;
|
|
|
|
use winit::window::WindowBuilder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use crate::button_m::Slider;
|
|
|
|
use crate::canvas::canvas_frame::{CanvasFrame, Drawable, Eventable};
|
|
|
|
use crate::canvas::canvas_frame::{CanvasFrame, Drawable, Eventable};
|
|
|
|
|
|
|
|
use crate::canvas::canvas_state::CanvasState;
|
|
|
|
use crate::canvas::managed::handles::{CanvasFontHandle, CanvasTextureHandle, Handle};
|
|
|
|
use crate::canvas::managed::handles::{CanvasFontHandle, CanvasTextureHandle, Handle};
|
|
|
|
use crate::compute::compu_frame::CompuFrame;
|
|
|
|
use crate::compute::compu_frame::CompuFrame;
|
|
|
|
use crate::compute::managed::handles::{CompuBufferHandle, CompuKernelHandle};
|
|
|
|
use crate::compute::managed::handles::{CompuBufferHandle, CompuKernelHandle};
|
|
|
@ -33,13 +37,9 @@ use crate::drawables::sprite::Sprite;
|
|
|
|
use crate::drawables::text::Text;
|
|
|
|
use crate::drawables::text::Text;
|
|
|
|
use crate::util::load_raw;
|
|
|
|
use crate::util::load_raw;
|
|
|
|
use crate::util::timer::Timer;
|
|
|
|
use crate::util::timer::Timer;
|
|
|
|
|
|
|
|
use crate::util::tr_event::TrEvent;
|
|
|
|
use crate::util::vertex::{TextureVertex3D, VertexType};
|
|
|
|
use crate::util::vertex::{TextureVertex3D, VertexType};
|
|
|
|
use crate::vkprocessor::VkProcessor;
|
|
|
|
use crate::vkprocessor::VkProcessor;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
use gilrs::{Gilrs, Button, Event as GilEvent, GamepadId, Gamepad};
|
|
|
|
|
|
|
|
use crate::util::tr_event::TrEvent;
|
|
|
|
|
|
|
|
use crate::button_m::Slider;
|
|
|
|
|
|
|
|
use crate::canvas::canvas_state::CanvasState;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub mod util;
|
|
|
|
pub mod util;
|
|
|
|
pub mod vkprocessor;
|
|
|
|
pub mod vkprocessor;
|
|
|
@ -48,12 +48,14 @@ pub mod canvas;
|
|
|
|
pub mod compute;
|
|
|
|
pub mod compute;
|
|
|
|
|
|
|
|
|
|
|
|
pub mod button_m {
|
|
|
|
pub mod button_m {
|
|
|
|
use crate::drawables::rect::Rect;
|
|
|
|
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
|
|
|
|
use std::collections::HashSet;
|
|
|
|
use std::collections::HashSet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use winit::event::Event;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::canvas::canvas_frame::{Drawable, Eventable};
|
|
|
|
use crate::canvas::canvas_frame::{Drawable, Eventable};
|
|
|
|
|
|
|
|
use crate::drawables::rect::Rect;
|
|
|
|
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
use crate::util::vertex::VertexType;
|
|
|
|
use crate::util::vertex::VertexType;
|
|
|
|
use winit::event::Event;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct Slider {
|
|
|
|
pub struct Slider {
|
|
|
|
handle: Rect,
|
|
|
|
handle: Rect,
|
|
|
@ -89,7 +91,7 @@ pub mod button_m {
|
|
|
|
scaler: 255,
|
|
|
|
scaler: 255,
|
|
|
|
position,
|
|
|
|
position,
|
|
|
|
size,
|
|
|
|
size,
|
|
|
|
value
|
|
|
|
value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,8 +111,8 @@ pub mod button_m {
|
|
|
|
unimplemented!()
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
pub fn main() {
|
|
|
|
hprof::start_frame();
|
|
|
|
hprof::start_frame();
|
|
|
|
|
|
|
|
|
|
|
@ -188,7 +190,7 @@ pub fn main() {
|
|
|
|
let slider = button_m::Slider::new((0.3, 0.04), (-0.5, -0.3), 30000);
|
|
|
|
let slider = button_m::Slider::new((0.3, 0.04), (-0.5, -0.3), 30000);
|
|
|
|
|
|
|
|
|
|
|
|
// how do i register a sprite to get events...
|
|
|
|
// how do i register a sprite to get events...
|
|
|
|
// explicit is much easier
|
|
|
|
// explicit is much easieri.lo
|
|
|
|
|
|
|
|
|
|
|
|
//let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
|
|
|
|
//let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
|
|
|
|
// let text_sprite = Text::new((-0.1, -0.1), (10.0, 10.0), 1);
|
|
|
|
// let text_sprite = Text::new((-0.1, -0.1), (10.0, 10.0), 1);
|
|
|
@ -202,7 +204,6 @@ pub fn main() {
|
|
|
|
let event_loop_proxy = events_loop.create_proxy();
|
|
|
|
let event_loop_proxy = events_loop.create_proxy();
|
|
|
|
|
|
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
|
|
|
|
|
|
|
|
let mut gilrs = Gilrs::new().unwrap();
|
|
|
|
let mut gilrs = Gilrs::new().unwrap();
|
|
|
|
// Iterate over all connected gamepads
|
|
|
|
// Iterate over all connected gamepads
|
|
|
|
let mut gamepad: Option<Gamepad> = None;
|
|
|
|
let mut gamepad: Option<Gamepad> = None;
|
|
|
@ -215,7 +216,6 @@ pub fn main() {
|
|
|
|
let mut active_gamepad = None;
|
|
|
|
let mut active_gamepad = None;
|
|
|
|
|
|
|
|
|
|
|
|
loop {
|
|
|
|
loop {
|
|
|
|
|
|
|
|
|
|
|
|
while let Some(GilEvent { id, event, time }) = gilrs.next_event() {
|
|
|
|
while let Some(GilEvent { id, event, time }) = gilrs.next_event() {
|
|
|
|
println!("{:?} New event from {}: {:?}", time, id, event);
|
|
|
|
println!("{:?} New event from {}: {:?}", time, id, event);
|
|
|
|
active_gamepad = Some(id);
|
|
|
|
active_gamepad = Some(id);
|
|
|
@ -232,10 +232,11 @@ pub fn main() {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(50));
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(50));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut event_stack = Vec::new();
|
|
|
|
|
|
|
|
|
|
|
|
// Events loop is borrowed from the surface
|
|
|
|
// Events loop is borrowed from the surface
|
|
|
|
events_loop.run(move |event, _, control_flow| {
|
|
|
|
events_loop.run(move |event, _, control_flow| {
|
|
|
|
*control_flow = ControlFlow::Poll;
|
|
|
|
*control_flow = ControlFlow::Poll;
|
|
|
@ -243,28 +244,32 @@ pub fn main() {
|
|
|
|
let mut previous_canvas = CanvasFrame::default();
|
|
|
|
let mut previous_canvas = CanvasFrame::default();
|
|
|
|
|
|
|
|
|
|
|
|
match event {
|
|
|
|
match event {
|
|
|
|
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } =>
|
|
|
|
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
|
|
|
|
{
|
|
|
|
|
|
|
|
*control_flow = ControlFlow::Exit
|
|
|
|
*control_flow = ControlFlow::Exit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Event::WindowEvent { event: WindowEvent::Resized(_), .. } => {
|
|
|
|
Event::WindowEvent { event: WindowEvent::Resized(_), .. } => {
|
|
|
|
processor.swapchain_recreate_needed = true;
|
|
|
|
processor.swapchain_recreate_needed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Event::UserEvent(TrEvent::KeyHeldEvent { }) => {
|
|
|
|
Event::WindowEvent {
|
|
|
|
}
|
|
|
|
event: WindowEvent::MouseInput {
|
|
|
|
Event::UserEvent(TrEvent::MouseHeldEvent { }) => {
|
|
|
|
device_id, state, button, modifiers
|
|
|
|
}
|
|
|
|
}, ..
|
|
|
|
Event::UserEvent(TrEvent::GamepadEvent { gil_event }) => {
|
|
|
|
} => {
|
|
|
|
|
|
|
|
event_stack.push(event.clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Event::UserEvent(TrEvent::KeyHeldEvent {}) => {}
|
|
|
|
|
|
|
|
Event::UserEvent(TrEvent::MouseHeldEvent {}) => {}
|
|
|
|
|
|
|
|
Event::UserEvent(TrEvent::GamepadEvent { gil_event }) => {}
|
|
|
|
Event::DeviceEvent { event: DeviceEvent::Key(keyboard_input), .. } => {
|
|
|
|
Event::DeviceEvent { event: DeviceEvent::Key(keyboard_input), .. } => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event_stack.push(event);
|
|
|
|
|
|
|
|
|
|
|
|
match keyboard_input.virtual_keycode.unwrap() {
|
|
|
|
match keyboard_input.virtual_keycode.unwrap() {
|
|
|
|
VirtualKeyCode::A => {
|
|
|
|
VirtualKeyCode::A => {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
// processor.save_edges_image();
|
|
|
|
// processor.save_edges_image();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
VirtualKeyCode::P => {
|
|
|
|
VirtualKeyCode::P => {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
let data = processor.read_compute_buffer(compute_buffer.clone());
|
|
|
|
let data = processor.read_compute_buffer(compute_buffer.clone());
|
|
|
@ -309,29 +314,22 @@ pub fn main() {
|
|
|
|
canvas_frame,
|
|
|
|
canvas_frame,
|
|
|
|
compu_frame);
|
|
|
|
compu_frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => ()
|
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// bucket the events out, but not really
|
|
|
|
// bucket the events out, but not really
|
|
|
|
match event {
|
|
|
|
match event {
|
|
|
|
Event::NewEvents(_) => {},
|
|
|
|
Event::NewEvents(_) => {}
|
|
|
|
Event::WindowEvent { window_id, event } => {
|
|
|
|
Event::WindowEvent { window_id, event } => {}
|
|
|
|
|
|
|
|
Event::DeviceEvent { device_id, event } => {}
|
|
|
|
},
|
|
|
|
Event::UserEvent(tr_event) => {}
|
|
|
|
Event::DeviceEvent { device_id, event } => {
|
|
|
|
Event::Suspended => {}
|
|
|
|
|
|
|
|
Event::Resumed => {}
|
|
|
|
},
|
|
|
|
Event::MainEventsCleared => {}
|
|
|
|
Event::UserEvent(tr_event) => {
|
|
|
|
Event::RedrawRequested(_) => {}
|
|
|
|
|
|
|
|
Event::RedrawEventsCleared => {}
|
|
|
|
},
|
|
|
|
Event::LoopDestroyed => {}
|
|
|
|
Event::Suspended => {},
|
|
|
|
|
|
|
|
Event::Resumed => {},
|
|
|
|
|
|
|
|
Event::MainEventsCleared => {},
|
|
|
|
|
|
|
|
Event::RedrawRequested(_) => {},
|
|
|
|
|
|
|
|
Event::RedrawEventsCleared => {},
|
|
|
|
|
|
|
|
Event::LoopDestroyed => {},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -342,18 +340,13 @@ pub fn main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn click_test(event_loop_proxy: EventLoopProxy<TrEvent>, canvas_state: &CanvasState) {
|
|
|
|
pub fn click_test(event_loop_proxy: EventLoopProxy<TrEvent>, canvas_state: &CanvasState) {
|
|
|
|
|
|
|
|
// for i in canvas_state. {
|
|
|
|
for i in canvas_state. {
|
|
|
|
// event_loop_proxy.send_event(TrEvent::MouseClickEvent {
|
|
|
|
|
|
|
|
// position: (0.0, 0.0),
|
|
|
|
event_loop_proxy.send_event(TrEvent::MouseClickEvent {
|
|
|
|
// button: MouseButton::Left,
|
|
|
|
position: (0.0, 0.0),
|
|
|
|
// }).ok();
|
|
|
|
button: MouseButton::Left
|
|
|
|
// }
|
|
|
|
}).ok();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|