|
|
@ -26,7 +26,7 @@ use winit::platform::unix::WindowBuilderExtUnix;
|
|
|
|
use winit::window::WindowBuilder;
|
|
|
|
use winit::window::WindowBuilder;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::button_m::Slider;
|
|
|
|
use crate::button_m::Slider;
|
|
|
|
use crate::canvas::canvas_frame::{CanvasFrame, Drawable, Eventable};
|
|
|
|
use crate::canvas::canvas_frame::{CanvasFrame, Drawable, Eventable, Updatable};
|
|
|
|
use crate::canvas::canvas_state::CanvasState;
|
|
|
|
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;
|
|
|
@ -71,7 +71,6 @@ pub mod button_m {
|
|
|
|
pub fn new(size: (f32, f32), position: (f32, f32), value: u16) -> Slider {
|
|
|
|
pub fn new(size: (f32, f32), position: (f32, f32), value: u16) -> Slider {
|
|
|
|
|
|
|
|
|
|
|
|
// render the guide first
|
|
|
|
// render the guide first
|
|
|
|
|
|
|
|
|
|
|
|
let red = (1.0, 0.0, 0.0, 0.0);
|
|
|
|
let red = (1.0, 0.0, 0.0, 0.0);
|
|
|
|
let green = (0.0, 1.0, 0.0, 0.0);
|
|
|
|
let green = (0.0, 1.0, 0.0, 0.0);
|
|
|
|
let blue = (0.0, 1.0, 1.0, 0.0);
|
|
|
|
let blue = (0.0, 1.0, 1.0, 0.0);
|
|
|
@ -84,7 +83,6 @@ pub mod button_m {
|
|
|
|
let scale = value as f32 / u16::max_value() as f32;
|
|
|
|
let scale = value as f32 / u16::max_value() as f32;
|
|
|
|
let handle = Rect::new((position.0 + (size.0 * scale) as f32, position.1 as f32), (0.03, size.1), 1, rg);
|
|
|
|
let handle = Rect::new((position.0 + (size.0 * scale) as f32, position.1 as f32), (0.03, size.1), 1, rg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Slider {
|
|
|
|
Slider {
|
|
|
|
handle: handle,
|
|
|
|
handle: handle,
|
|
|
|
guide: vec![left_guide_bar, right_guide_bar, line],
|
|
|
|
guide: vec![left_guide_bar, right_guide_bar, line],
|
|
|
@ -97,7 +95,7 @@ pub mod button_m {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Drawable for Slider {
|
|
|
|
impl Drawable for Slider {
|
|
|
|
fn get(&self) -> Vec<VertexType> {
|
|
|
|
fn get(&self, window_size: (u32, u32)) -> Vec<VertexType> {
|
|
|
|
let mut vertices = vec![self.handle.verts.clone()];
|
|
|
|
let mut vertices = vec![self.handle.verts.clone()];
|
|
|
|
vertices.extend_from_slice(self.guide.iter()
|
|
|
|
vertices.extend_from_slice(self.guide.iter()
|
|
|
|
.map(|x| x.clone().verts).collect::<Vec<VertexType>>().as_slice()
|
|
|
|
.map(|x| x.clone().verts).collect::<Vec<VertexType>>().as_slice()
|
|
|
@ -114,12 +112,6 @@ pub mod button_m {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
pub fn main() {
|
|
|
|
hprof::start_frame();
|
|
|
|
hprof::start_frame();
|
|
|
|
|
|
|
|
|
|
|
@ -158,8 +150,9 @@ pub fn main() {
|
|
|
|
Box::new(sync::now(processor.device.clone())) as Box<dyn GpuFuture>;
|
|
|
|
Box::new(sync::now(processor.device.clone())) as Box<dyn GpuFuture>;
|
|
|
|
|
|
|
|
|
|
|
|
let step_size: f32 = 0.005;
|
|
|
|
let step_size: f32 = 0.005;
|
|
|
|
let mut elapsed_time: f32;
|
|
|
|
let mut elapsed_time: f32 = timer.elap_time();
|
|
|
|
let mut delta_time: f32;
|
|
|
|
;
|
|
|
|
|
|
|
|
let mut delta_time: f32 = 0.0;
|
|
|
|
let mut accumulator_time: f32 = 0.0;
|
|
|
|
let mut accumulator_time: f32 = 0.0;
|
|
|
|
let mut current_time: f32 = timer.elap_time();
|
|
|
|
let mut current_time: f32 = timer.elap_time();
|
|
|
|
|
|
|
|
|
|
|
@ -167,7 +160,7 @@ pub fn main() {
|
|
|
|
let image_dimensions_f: (f32, f32) = ((image_data.1).clone().0 as f32, (image_data.1).clone().1 as f32);
|
|
|
|
let image_dimensions_f: (f32, f32) = ((image_data.1).clone().0 as f32, (image_data.1).clone().1 as f32);
|
|
|
|
let image_dimensions_u: (u32, u32) = image_data.1;
|
|
|
|
let image_dimensions_u: (u32, u32) = image_data.1;
|
|
|
|
let compu_sprite1: CompuSprite =
|
|
|
|
let compu_sprite1: CompuSprite =
|
|
|
|
CompuSprite::new((0.0, -0.5), (1.0, 1.0), 0, image_dimensions_f,
|
|
|
|
CompuSprite::new((-1.0, -1.0), (1.0, 1.0), 0, image_dimensions_f,
|
|
|
|
// Swap image to render the result to. Must match dimensions
|
|
|
|
// Swap image to render the result to. Must match dimensions
|
|
|
|
processor.new_swap_image(image_dimensions_u));
|
|
|
|
processor.new_swap_image(image_dimensions_u));
|
|
|
|
|
|
|
|
|
|
|
@ -190,17 +183,15 @@ pub fn main() {
|
|
|
|
//let font_handle : Arc<CanvasFontHandle> =
|
|
|
|
//let font_handle : Arc<CanvasFontHandle> =
|
|
|
|
// processor.get_font_handle(String::from("sansation.ttf")).unwrap();
|
|
|
|
// processor.get_font_handle(String::from("sansation.ttf")).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let mut funky_sprite = Sprite::new((0.0, 0.5), (0.5, 0.5), 0, funky_handle.clone());
|
|
|
|
let mut funky_sprite = Sprite::new(
|
|
|
|
|
|
|
|
(200.0, 200.0),
|
|
|
|
|
|
|
|
(100.0, 150.0), 10, funky_handle.clone());
|
|
|
|
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 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...
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
//let test_polygon = Poly::new_with_color((-0.5, -0.5), (0.5, 0.5), 1, (1.0,0.0,0.0,0.0));
|
|
|
|
//let test_polygon = Poly::new_with_color((-0.5, -0.5), (0.5, 0.5), 1, (1.0,0.0,0.0,0.0));
|
|
|
|
|
|
|
|
|
|
|
|
drop(q2);
|
|
|
|
drop(q2);
|
|
|
@ -242,9 +233,13 @@ pub fn main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut window_size: (u32, u32) = (0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
let mut canvas_frame = CanvasFrame::default();
|
|
|
|
let mut canvas_frame = CanvasFrame::new(window_size);
|
|
|
|
let mut compu_frame = CompuFrame::new();
|
|
|
|
let mut compu_frame = CompuFrame::new(window_size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut container = Box::new(Slider::new((0.1, 0.1), (0.9, 0.9), 5000));
|
|
|
|
|
|
|
|
//container.push(Sprite::new((0.1)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Events loop is borrowed from the surface
|
|
|
|
// Events loop is borrowed from the surface
|
|
|
@ -259,21 +254,29 @@ pub fn main() {
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
canvas_frame.draw(&compu_sprite1);
|
|
|
|
canvas_frame.draw(&compu_sprite1);
|
|
|
|
canvas_frame.draw(&slider);
|
|
|
|
canvas_frame.draw(&slider);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window_size = surface.window().inner_size().into();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
elapsed_time = timer.elap_time();
|
|
|
|
|
|
|
|
delta_time = elapsed_time - current_time;
|
|
|
|
|
|
|
|
current_time = elapsed_time;
|
|
|
|
|
|
|
|
if delta_time > 0.02 {
|
|
|
|
|
|
|
|
delta_time = 0.02;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulator_time += delta_time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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(new_size), .. } => {
|
|
|
|
processor.swapchain_recreate_needed = true;
|
|
|
|
processor.swapchain_recreate_needed = true;
|
|
|
|
|
|
|
|
let size = (new_size.width, new_size.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Event::WindowEvent {
|
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::MouseInput {
|
|
|
|
event: WindowEvent::MouseInput {
|
|
|
|
device_id, state, button, modifiers
|
|
|
|
device_id, state, button, modifiers
|
|
|
|
}, ..
|
|
|
|
}, ..
|
|
|
|
} => {
|
|
|
|
} => {}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Event::UserEvent(TrEvent::KeyHeldEvent {}) => {}
|
|
|
|
Event::UserEvent(TrEvent::KeyHeldEvent {}) => {}
|
|
|
|
Event::UserEvent(TrEvent::MouseHeldEvent {}) => {}
|
|
|
|
Event::UserEvent(TrEvent::MouseHeldEvent {}) => {}
|
|
|
|
Event::UserEvent(TrEvent::GamepadEvent { gil_event }) => {}
|
|
|
|
Event::UserEvent(TrEvent::GamepadEvent { gil_event }) => {}
|
|
|
@ -282,13 +285,10 @@ pub fn main() {
|
|
|
|
DeviceEvent::Key(keyboard_input) => {
|
|
|
|
DeviceEvent::Key(keyboard_input) => {
|
|
|
|
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 {}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VirtualKeyCode::S => {
|
|
|
|
VirtualKeyCode::S => {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VirtualKeyCode::P => {
|
|
|
|
VirtualKeyCode::P => {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
@ -304,14 +304,16 @@ pub fn main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Event::MainEventsCleared => {
|
|
|
|
Event::MainEventsCleared => {
|
|
|
|
canvas_frame = CanvasFrame::default();
|
|
|
|
funky_sprite.update(delta_time);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canvas_frame = CanvasFrame::new(window_size);
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
canvas_frame.draw(&compu_sprite1);
|
|
|
|
// canvas_frame.draw(&compu_sprite1);
|
|
|
|
canvas_frame.draw(&slider);
|
|
|
|
canvas_frame.draw(&slider);
|
|
|
|
|
|
|
|
|
|
|
|
compu_frame = CompuFrame::new();
|
|
|
|
compu_frame = CompuFrame::new(window_size);
|
|
|
|
compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
|
|
|
// compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
|
|
|
compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
|
|
|
|
// compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let g = hprof::enter("Run");
|
|
|
|
let g = hprof::enter("Run");
|
|
|
@ -319,6 +321,10 @@ pub fn main() {
|
|
|
|
&canvas_frame,
|
|
|
|
&canvas_frame,
|
|
|
|
&compu_frame);
|
|
|
|
&compu_frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// while (accumulator_time - step_size) >= step_size {
|
|
|
|
|
|
|
|
// accumulator_time -= step_size;
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => ()
|
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -356,22 +362,8 @@ pub fn click_test(event_loop_proxy: EventLoopProxy<TrEvent>, canvas_state: &Canv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// while let true = processor.is_open() {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// // Take care of our timing
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// elapsed_time = timer.elap_time();
|
|
|
|
|
|
|
|
// delta_time = elapsed_time - current_time;
|
|
|
|
|
|
|
|
// current_time = elapsed_time;
|
|
|
|
|
|
|
|
// if delta_time > 0.02 {
|
|
|
|
|
|
|
|
// delta_time = 0.02;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// accumulator_time += delta_time;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// while (accumulator_time - step_size) >= step_size {
|
|
|
|
|
|
|
|
// accumulator_time -= step_size;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|