|
|
@ -99,19 +99,24 @@ pub fn main() {
|
|
|
|
let sprite = Sprite::new_with_color((0., 0.), (0.1, 0.1), (1., 0., 0., 1.));
|
|
|
|
let sprite = Sprite::new_with_color((0., 0.), (0.1, 0.1), (1., 0., 0., 1.));
|
|
|
|
let sprite2 = Sprite::new_with_color((-0.3, -0.5), (0.1, 0.1), (0., 1., 0., 1.));
|
|
|
|
let sprite2 = Sprite::new_with_color((-0.3, -0.5), (0.1, 0.1), (0., 1., 0., 1.));
|
|
|
|
|
|
|
|
|
|
|
|
let compu_sprite1 = CompuSprite::new((-1., -0.5), (1.0, 1.0), (400.0, 400.0),
|
|
|
|
let image_data = load_raw(String::from("funky-bird.jpg"));
|
|
|
|
|
|
|
|
let image_dimensions_f = ((image_data.1).0 as f32, (image_data.1).1 as f32);
|
|
|
|
|
|
|
|
let image_dimensions_u = image_data.1;
|
|
|
|
|
|
|
|
let compu_sprite1 = CompuSprite::new((-1., -0.5), (1.0, 1.0), image_dimensions_f,
|
|
|
|
// This swap image needs to match the size of the compute
|
|
|
|
// This swap image needs to match the size of the compute
|
|
|
|
processor.new_swap_image((400, 400)));
|
|
|
|
processor.new_swap_image(image_dimensions_u));
|
|
|
|
|
|
|
|
|
|
|
|
let image_data = load_raw(String::from("test2.png"));
|
|
|
|
|
|
|
|
let compute_buffer = processor.new_compute_buffer(image_data.0, image_data.1, 4);
|
|
|
|
let compute_buffer = processor.new_compute_buffer(image_data.0, image_data.1, 4);
|
|
|
|
|
|
|
|
|
|
|
|
let compute_kernel = processor.get_kernel_handle(String::from("simple-edge.compute"))
|
|
|
|
let compute_kernel = processor.get_kernel_handle(String::from("simple-edge.compute"))
|
|
|
|
.expect("Can't find that kernel");
|
|
|
|
.expect("Can't find that kernel");
|
|
|
|
|
|
|
|
|
|
|
|
let handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap();
|
|
|
|
let funky_handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap();
|
|
|
|
|
|
|
|
let sfml_handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let sprite3 = Sprite::new_with_texture((0.0, -0.5), (0.5, 0.5), funky_handle.clone());
|
|
|
|
|
|
|
|
let sprite4 = Sprite::new_with_texture((0.3, 0.5), (0.9, 0.9), sfml_handle.clone());
|
|
|
|
|
|
|
|
|
|
|
|
let sprite3 = Sprite::new_with_texture((0.3, 0.5), (0.5, 0.5), handle.clone());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drop(q2);
|
|
|
|
drop(q2);
|
|
|
|
drop(q1);
|
|
|
|
drop(q1);
|
|
|
@ -120,6 +125,9 @@ pub fn main() {
|
|
|
|
|
|
|
|
|
|
|
|
let mut exit = false;
|
|
|
|
let mut exit = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while let Some(p) = window.get_position() {
|
|
|
|
while let Some(p) = window.get_position() {
|
|
|
|
elapsed_time = timer.elap_time();
|
|
|
|
elapsed_time = timer.elap_time();
|
|
|
|
delta_time = elapsed_time - current_time;
|
|
|
|
delta_time = elapsed_time - current_time;
|
|
|
@ -168,9 +176,16 @@ pub fn main() {
|
|
|
|
compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
|
|
|
|
compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if elapsed_time > (count) as f32 {
|
|
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
compu_frame.add_chained(compute_buffer.clone(), compute_buffer.clone(), compute_kernel.clone());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let mut canvas = CanvasFrame::new();
|
|
|
|
let mut canvas = CanvasFrame::new();
|
|
|
|
canvas.draw(&sprite);
|
|
|
|
canvas.draw(&sprite);
|
|
|
|
canvas.draw(&sprite2);
|
|
|
|
canvas.draw(&sprite2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canvas.draw(&sprite4);
|
|
|
|
canvas.draw(&sprite3);
|
|
|
|
canvas.draw(&sprite3);
|
|
|
|
canvas.draw(&compu_sprite1);
|
|
|
|
canvas.draw(&compu_sprite1);
|
|
|
|
|
|
|
|
|
|
|
|