|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
use specs::{Component, Join, System, VecStorage, Write, WriteStorage};
|
|
|
|
|
|
|
|
|
|
use crate::canvas::canvas_frame::CanvasFrame;
|
|
|
|
|
use crate::canvas::compu_frame::CompuFrame;
|
|
|
|
|
use crate::canvas::managed::handles::{CanvasImageHandle, CanvasTextureHandle};
|
|
|
|
|
use crate::PersistentState;
|
|
|
|
|
use crate::util::vertex::{TextureVertex3D, VertexTypeContainer, ImageVertex3D};
|
|
|
|
|
use crate::util::vertex::{ImageVertex3D, TextureVertex3D, VertexTypeContainer};
|
|
|
|
|
use crate::vkprocessor::VkProcessor;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct Position {
|
|
|
|
@ -81,7 +82,6 @@ impl<'a> System<'a> for RenderSystem {
|
|
|
|
|
mut vk_processor
|
|
|
|
|
): Self::SystemData) {
|
|
|
|
|
state.canvas_frame = CanvasFrame::new(state.window_size);
|
|
|
|
|
state.compu_frame = CompuFrame::new(state.window_size);
|
|
|
|
|
|
|
|
|
|
// compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
|
|
|
|
// compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
|
|
|
|
@ -98,7 +98,7 @@ impl<'a> System<'a> for RenderSystem {
|
|
|
|
|
let textured_vertices = vec![
|
|
|
|
|
VertexTypeContainer::TextureType(
|
|
|
|
|
generate_textured_verts(window_size, pos, size, normalized_depth),
|
|
|
|
|
textures.textures.get(0).unwrap().clone()
|
|
|
|
|
textures.textures.get(0).unwrap().clone(),
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
@ -117,16 +117,17 @@ impl<'a> System<'a> for RenderSystem {
|
|
|
|
|
let textured_vertices = vec![
|
|
|
|
|
VertexTypeContainer::ImageType(
|
|
|
|
|
generate_image_verts(window_size, pos, size, images.image_resolutions.get(0).unwrap().clone(), normalized_depth),
|
|
|
|
|
images.images.get(0).unwrap().clone()
|
|
|
|
|
images.images.get(0).unwrap().clone(),
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
state.canvas_frame.add(textured_vertices);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let compu_frame = &state.compu_frame;
|
|
|
|
|
vk_processor.run(&state.surface.clone().unwrap(),
|
|
|
|
|
&state.canvas_frame,
|
|
|
|
|
&state.compu_frame);
|
|
|
|
|
compu_frame);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -137,7 +138,6 @@ fn generate_image_verts(
|
|
|
|
|
image_size: (u32, u32),
|
|
|
|
|
depth: f32,
|
|
|
|
|
) -> Vec<ImageVertex3D> {
|
|
|
|
|
|
|
|
|
|
let image_size = (image_size.0 as f32, image_size.1 as f32);
|
|
|
|
|
|
|
|
|
|
// screen space position
|
|
|
|
@ -161,27 +161,27 @@ fn generate_image_verts(
|
|
|
|
|
vec![
|
|
|
|
|
ImageVertex3D {
|
|
|
|
|
v_position: [ss_position.0, ss_position.1, depth], // top left
|
|
|
|
|
ti_position: [-0.0, -0.0]
|
|
|
|
|
ti_position: [-0.0, -0.0],
|
|
|
|
|
},
|
|
|
|
|
ImageVertex3D {
|
|
|
|
|
v_position: [ss_position.0, ss_position.1 + ss_size.1, depth], // bottom left
|
|
|
|
|
ti_position: [-0.0, image_size.1]
|
|
|
|
|
ti_position: [-0.0, image_size.1],
|
|
|
|
|
},
|
|
|
|
|
ImageVertex3D {
|
|
|
|
|
v_position: [ss_position.0 + ss_size.0, ss_position.1 + ss_size.1, depth], // bottom right
|
|
|
|
|
ti_position: [image_size.0, image_size.1]
|
|
|
|
|
ti_position: [image_size.0, image_size.1],
|
|
|
|
|
},
|
|
|
|
|
ImageVertex3D {
|
|
|
|
|
v_position: [ss_position.0, ss_position.1, depth], // top left
|
|
|
|
|
ti_position: [-0.0, -0.0]
|
|
|
|
|
ti_position: [-0.0, -0.0],
|
|
|
|
|
},
|
|
|
|
|
ImageVertex3D {
|
|
|
|
|
v_position: [ss_position.0 + ss_size.0, ss_position.1 + ss_size.1, depth], // bottom right
|
|
|
|
|
ti_position: [image_size.0, image_size.1]
|
|
|
|
|
ti_position: [image_size.0, image_size.1],
|
|
|
|
|
},
|
|
|
|
|
ImageVertex3D {
|
|
|
|
|
v_position: [ss_position.0 + ss_size.0, ss_position.1, depth], // top right
|
|
|
|
|
ti_position: [image_size.0, -0.0]
|
|
|
|
|
ti_position: [image_size.0, -0.0],
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
@ -192,7 +192,6 @@ fn generate_textured_verts(
|
|
|
|
|
size: (f32, f32),
|
|
|
|
|
depth: f32,
|
|
|
|
|
) -> Vec<TextureVertex3D> {
|
|
|
|
|
|
|
|
|
|
let ss_position = (
|
|
|
|
|
position.0 / window_size.0 as f32 - 1.0,
|
|
|
|
|
position.1 / window_size.1 as f32 - 1.0
|
|
|
|
|