|
|
@ -60,7 +60,7 @@ impl<'t> Edge<'t> {
|
|
|
|
let mut surface = RenderTexture::new(800, 600, false).unwrap();
|
|
|
|
let mut surface = RenderTexture::new(800, 600, false).unwrap();
|
|
|
|
surface.set_smooth(true);
|
|
|
|
surface.set_smooth(true);
|
|
|
|
let mut bg_sprite = Sprite::with_texture(bg_texture);
|
|
|
|
let mut bg_sprite = Sprite::with_texture(bg_texture);
|
|
|
|
bg_sprite.set_position((135., 100.));
|
|
|
|
bg_sprite.set_position((0., 0.));
|
|
|
|
let mut entities = Vec::new();
|
|
|
|
let mut entities = Vec::new();
|
|
|
|
|
|
|
|
|
|
|
|
for i in 0..6 {
|
|
|
|
for i in 0..6 {
|
|
|
@ -174,7 +174,12 @@ fn main() {
|
|
|
|
let mut img = image::open("resources/images/funky-bird.jpg").unwrap();
|
|
|
|
let mut img = image::open("resources/images/funky-bird.jpg").unwrap();
|
|
|
|
let xy = img.dimensions();
|
|
|
|
let xy = img.dimensions();
|
|
|
|
let data_length = xy.0*xy.1*3;
|
|
|
|
let data_length = xy.0*xy.1*3;
|
|
|
|
|
|
|
|
|
|
|
|
println!("Buffer length {}", data_length);
|
|
|
|
println!("Buffer length {}", data_length);
|
|
|
|
|
|
|
|
println!("Buffer length {}", img.raw_pixels().len());
|
|
|
|
|
|
|
|
println!("Size {:?}", xy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut image_buffer = Vec::new();
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Pull out the image data and place it in a sync'd CPU<->GPU buffer
|
|
|
|
// Pull out the image data and place it in a sync'd CPU<->GPU buffer
|
|
|
@ -193,7 +198,7 @@ fn main() {
|
|
|
|
|
|
|
|
|
|
|
|
// The command buffer I think pretty much serves to define what runs where for how many times
|
|
|
|
// The command buffer I think pretty much serves to define what runs where for how many times
|
|
|
|
let command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(device.clone(), queue.family()).unwrap()
|
|
|
|
let command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(device.clone(), queue.family()).unwrap()
|
|
|
|
.dispatch([1024, 1, 1], pipeline.clone(), set.clone(), ()).unwrap()
|
|
|
|
.dispatch([xy.0, xy.1, 1], pipeline.clone(), set.clone(), ()).unwrap()
|
|
|
|
.build().unwrap();
|
|
|
|
.build().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
// Create a future for running the command buffer and then just fence it
|
|
|
|
// Create a future for running the command buffer and then just fence it
|
|
|
@ -202,22 +207,25 @@ fn main() {
|
|
|
|
.then_signal_fence_and_flush().unwrap();
|
|
|
|
.then_signal_fence_and_flush().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
// I think this is redundant and returns immediately
|
|
|
|
// I think this is redundant and returns immediately
|
|
|
|
future.wait(None).unwrap();
|
|
|
|
// future.wait(None).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
// The buffer is sync'd so we can just read straight from the handle
|
|
|
|
// The buffer is sync'd so we can just read straight from the handle
|
|
|
|
let data_buffer_content = data_buffer.read().unwrap();
|
|
|
|
let data_buffer_content = data_buffer.read().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
for y in 0 .. xy.1 {
|
|
|
|
for x in 0 .. xy.0 {
|
|
|
|
for x in 0 .. xy.0 {
|
|
|
|
for y in 0 .. xy.1 {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let r = data_buffer_content[((xy.0 * y + x) * 3 + 0) as usize] as u8;
|
|
|
|
let r = data_buffer_content[((xy.0 * y + x) * 3 + 0) as usize] as u8;
|
|
|
|
let g = data_buffer_content[((xy.0 * y + x) * 3 + 1) as usize] as u8;
|
|
|
|
let g = data_buffer_content[((xy.0 * y + x) * 3 + 1) as usize] as u8;
|
|
|
|
let b = data_buffer_content[((xy.0 * y + x) * 3 + 2) as usize] as u8;
|
|
|
|
let b = data_buffer_content[((xy.0 * y + x) * 3 + 2) as usize] as u8;
|
|
|
|
// let a = data_buffer_content[((xy.0 * y + x) * 4 + 3) as usize] as u8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let old = img.get_pixel(x, y);
|
|
|
|
image_buffer.push(r);
|
|
|
|
img.put_pixel(x, y, image::Rgba([r, g, b, 0]));
|
|
|
|
image_buffer.push(g);
|
|
|
|
|
|
|
|
image_buffer.push(b);
|
|
|
|
|
|
|
|
image_buffer.push(255);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
img.put_pixel(x, y, image::Rgba([r, g, b, 255]))
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -227,7 +235,7 @@ fn main() {
|
|
|
|
println!("Starting");
|
|
|
|
println!("Starting");
|
|
|
|
|
|
|
|
|
|
|
|
let mut window = RenderWindow::new(
|
|
|
|
let mut window = RenderWindow::new(
|
|
|
|
(512, 512),
|
|
|
|
(900, 900),
|
|
|
|
"Custom drawable",
|
|
|
|
"Custom drawable",
|
|
|
|
Style::CLOSE,
|
|
|
|
Style::CLOSE,
|
|
|
|
&Default::default(),
|
|
|
|
&Default::default(),
|
|
|
@ -239,7 +247,9 @@ fn main() {
|
|
|
|
//==========================================
|
|
|
|
//==========================================
|
|
|
|
let font = Font::from_file("resources/fonts/sansation.ttf").unwrap();
|
|
|
|
let font = Font::from_file("resources/fonts/sansation.ttf").unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let mut bg_texture = Texture::from_file("output.png").unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let mut bg_texture = Texture::new(xy.0, xy.1).unwrap();
|
|
|
|
|
|
|
|
bg_texture.update_from_pixels(image_buffer.as_slice(), xy.0, xy.1, 0, 0);
|
|
|
|
//let mut bg_texture = Texture::from_file("resources/images/sfml.png").unwrap();
|
|
|
|
//let mut bg_texture = Texture::from_file("resources/images/sfml.png").unwrap();
|
|
|
|
//bg_texture.set_smooth(true);
|
|
|
|
//bg_texture.set_smooth(true);
|
|
|
|
|
|
|
|
|
|
|
|