Added sprite and better vertex format. works, but now I lost texturing
This commit is contained in:
66
src/main.rs
66
src/main.rs
@@ -46,7 +46,7 @@ use crate::workpiece::{WorkpieceLoader, Workpiece};
|
||||
use winit::{EventsLoop, WindowBuilder, WindowEvent, Event, DeviceEvent, VirtualKeyCode, ElementState};
|
||||
use winit::dpi::LogicalSize;
|
||||
use vulkano_win::VkSurfaceBuild;
|
||||
|
||||
use sprite::Sprite;
|
||||
|
||||
mod slider;
|
||||
mod timer;
|
||||
@@ -55,28 +55,9 @@ mod vkprocessor;
|
||||
mod util;
|
||||
mod button;
|
||||
mod workpiece;
|
||||
|
||||
|
||||
//struct Sprite {
|
||||
// pub texture:
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
How the F am I going to do sprites?
|
||||
|
||||
I need sprites for the slider and buttons at least
|
||||
|
||||
The background + render of the toolpath can probably just be straight up hand manipulated textures
|
||||
|
||||
Sprite will have 4 verticies and a texture along with position and size attributes
|
||||
|
||||
|
||||
|
||||
*/
|
||||
mod vertex_2d;
|
||||
mod vertex_3d;
|
||||
mod sprite;
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -91,18 +72,13 @@ fn main() {
|
||||
.build_vk_surface(&events_loop, instance.clone()).unwrap();
|
||||
let mut window = surface.window();
|
||||
|
||||
|
||||
let mut processor = vkprocessor::VkProcessor::new(&instance, &surface);
|
||||
|
||||
processor.compile_kernel(String::from("simple-edge.compute"));
|
||||
processor.compile_shaders(String::from("simple_texture"), &surface);
|
||||
|
||||
processor.load_buffers(String::from("background.jpg"));
|
||||
|
||||
|
||||
let mut timer = Timer::new();
|
||||
// let mut input = Input::new();
|
||||
|
||||
let mut frame_future = Box::new(sync::now(processor.device.clone())) as Box<dyn GpuFuture>;
|
||||
|
||||
let step_size: f32 = 0.005;
|
||||
let mut elapsed_time: f32;
|
||||
@@ -113,36 +89,11 @@ fn main() {
|
||||
let mut mouse_xy = Vector2i::new(0,0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let mut s = Box::new(sync::now(processor.device.clone())) as Box<dyn GpuFuture>;
|
||||
Sprite::new_with_color((0.,0.), (0,0), (0.,0.,0.,0.));
|
||||
|
||||
|
||||
while let Some(p) = window.get_position() {
|
||||
|
||||
// Event::MouseButtonPressed { button, x, y} => {
|
||||
// let x = x as u32;
|
||||
// let y = y as u32;
|
||||
// mouse_xy = mouse::desktop_position();
|
||||
// let r = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 0) as usize] as u8;
|
||||
// let g = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 1) as usize] as u8;
|
||||
// let b = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 2) as usize] as u8;
|
||||
// let a = processor.image_buffer[((processor.xy.0 * y + x) * 4 + 3) as usize] as u8;
|
||||
//
|
||||
// selected_colors.push(
|
||||
// RectangleShape::with_size(Vector2f::new(30.0, 30.0))
|
||||
// );
|
||||
//
|
||||
// let mut x_position = 45.0 * selected_colors.len() as f32;
|
||||
//
|
||||
// selected_colors.last_mut().unwrap().set_position(Vector2f::new(x_position, 80.0));
|
||||
// selected_colors.last_mut().unwrap().set_fill_color(&Color::rgba(r,g,b,a));
|
||||
// }
|
||||
|
||||
|
||||
elapsed_time = timer.elap_time();
|
||||
delta_time = elapsed_time - current_time;
|
||||
current_time = elapsed_time;
|
||||
@@ -176,6 +127,9 @@ fn main() {
|
||||
_ => ()
|
||||
}
|
||||
},
|
||||
// Event::DeviceEvent { event: DeviceEvent::Button(mouse_input), .. } => {
|
||||
// mouse_xy.x
|
||||
// },
|
||||
_ => ()
|
||||
}
|
||||
});
|
||||
@@ -185,7 +139,7 @@ fn main() {
|
||||
}
|
||||
|
||||
|
||||
s = processor.run(&surface, s);
|
||||
frame_future = processor.run(&surface, frame_future);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user