eventing will be slightly harder
This commit is contained in:
@@ -58,7 +58,6 @@ impl CompuFrame {
|
|||||||
buffer: Arc<CompuBufferHandle>,
|
buffer: Arc<CompuBufferHandle>,
|
||||||
kernel: Arc<CompuKernelHandle>,
|
kernel: Arc<CompuKernelHandle>,
|
||||||
images: &Images,
|
images: &Images,
|
||||||
geom: Geometry,
|
|
||||||
) {
|
) {
|
||||||
self.swapped_to_image.push((buffer, images.images.get(0).unwrap().clone(), kernel))
|
self.swapped_to_image.push((buffer, images.images.get(0).unwrap().clone(), kernel))
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ pub struct CompuSystem;
|
|||||||
impl<'a> System<'a> for CompuSystem {
|
impl<'a> System<'a> for CompuSystem {
|
||||||
type SystemData = (
|
type SystemData = (
|
||||||
WriteStorage<'a, Compu>,
|
WriteStorage<'a, Compu>,
|
||||||
WriteStorage<'a, Geometry>,
|
|
||||||
WriteStorage<'a, Images>,
|
WriteStorage<'a, Images>,
|
||||||
Write<'a, PersistentState>, // delta_time, window size, etc.
|
Write<'a, PersistentState>, // delta_time, window size, etc.
|
||||||
Write<'a, VkProcessor>, // Renderer
|
Write<'a, VkProcessor>, // Renderer
|
||||||
@@ -32,7 +31,6 @@ impl<'a> System<'a> for CompuSystem {
|
|||||||
|
|
||||||
fn run(&mut self, (
|
fn run(&mut self, (
|
||||||
mut compu_list,
|
mut compu_list,
|
||||||
mut geom_list,
|
|
||||||
mut image_list,
|
mut image_list,
|
||||||
mut state,
|
mut state,
|
||||||
mut vk_processor
|
mut vk_processor
|
||||||
@@ -42,12 +40,11 @@ impl<'a> System<'a> for CompuSystem {
|
|||||||
// 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());
|
||||||
|
|
||||||
for (compute_item, geom, image) in (&mut compu_list, &mut geom_list, &mut image_list).join() {
|
for (compute_item, image) in (&mut compu_list, &mut image_list).join() {
|
||||||
state.compu_frame.add_with_image_swap(
|
state.compu_frame.add_with_image_swap(
|
||||||
compute_item.buffers.get(0).unwrap().clone(),
|
compute_item.buffers.get(0).unwrap().clone(),
|
||||||
compute_item.kernels.get(0).unwrap().clone(),
|
compute_item.kernels.get(0).unwrap().clone(),
|
||||||
image,
|
image,
|
||||||
geom.clone(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
35
src/main.rs
35
src/main.rs
@@ -39,7 +39,7 @@ use crate::drawables::rect::Rect;
|
|||||||
use crate::drawables::slider::Slider;
|
use crate::drawables::slider::Slider;
|
||||||
use crate::drawables::sprite::Sprite;
|
use crate::drawables::sprite::Sprite;
|
||||||
use crate::drawables::text::Text;
|
use crate::drawables::text::Text;
|
||||||
use crate::render_system::{Geometry, Images, Position, Render, RenderSystem, Textures};
|
use crate::render_system::{Geometry, Images, Position, RenderSystem, Textures};
|
||||||
use crate::util::load_raw;
|
use crate::util::load_raw;
|
||||||
use crate::util::timer::Timer;
|
use crate::util::timer::Timer;
|
||||||
use crate::util::tr_event::{TrEvent, TrEventExtension};
|
use crate::util::tr_event::{TrEvent, TrEventExtension};
|
||||||
@@ -54,6 +54,14 @@ pub mod canvas;
|
|||||||
pub mod render_system;
|
pub mod render_system;
|
||||||
pub mod compu_system;
|
pub mod compu_system;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct Evented {
|
||||||
|
subscribed: fn(event: TrEvent<TrEventExtension>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Component for Evented {
|
||||||
|
type Storage = VecStorage<Self>;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PersistentState {
|
pub struct PersistentState {
|
||||||
@@ -68,16 +76,20 @@ struct EventSystem;
|
|||||||
|
|
||||||
impl<'a> System<'a> for EventSystem {
|
impl<'a> System<'a> for EventSystem {
|
||||||
type SystemData = (
|
type SystemData = (
|
||||||
|
Entities<'a>,
|
||||||
|
WriteStorage<'a, Evented>,
|
||||||
Write<'a, PersistentState>,
|
Write<'a, PersistentState>,
|
||||||
Write<'a, VkProcessor>,
|
Write<'a, VkProcessor>,
|
||||||
Write<'a, Vec<TrEvent<TrEventExtension>>>
|
Write<'a, Vec<TrEvent<TrEventExtension>>>
|
||||||
);
|
);
|
||||||
|
|
||||||
fn run(&mut self, (mut state, mut vk_processor, event_stack): Self::SystemData) {
|
fn run(&mut self, (entity, mut evented_list, mut state, mut vk_processor, event_stack): Self::SystemData) {
|
||||||
|
|
||||||
|
for (entity, evented) in (&*entity, &mut evented_list).join() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
//hprof::start_frame();
|
//hprof::start_frame();
|
||||||
@@ -140,7 +152,6 @@ pub fn main() {
|
|||||||
processor.get_texture_handle(String::from("sfml.png")).unwrap();
|
processor.get_texture_handle(String::from("sfml.png")).unwrap();
|
||||||
|
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.register::<Render>();
|
|
||||||
world.register::<Compu>();
|
world.register::<Compu>();
|
||||||
world.register::<Position>();
|
world.register::<Position>();
|
||||||
world.register::<Geometry>();
|
world.register::<Geometry>();
|
||||||
@@ -156,25 +167,21 @@ pub fn main() {
|
|||||||
compu_frame: CompuFrame::new((0, 0)),
|
compu_frame: CompuFrame::new((0, 0)),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// and the thing that renders it
|
||||||
world.create_entity()
|
world.create_entity()
|
||||||
.with(Compu { kernels: vec![compute_kernel], buffers: vec![compute_buffer] })// just a drawable
|
.with(Compu { kernels: vec![compute_kernel], buffers: vec![compute_buffer] })// just a drawable
|
||||||
.with(Geometry { size_x: 300.0, size_y: 300.0, rotation: 0.0 })
|
.with(Position { x: 900.0, y: 900.0, z: 0 })
|
||||||
.with(Images { images: vec![compu_image.clone()], image_resolutions: vec![image_dimensions_u] })
|
.with(Geometry { size_x: 600.0, size_y: 600.0, rotation: 0.0 })
|
||||||
|
.with(Images { images: vec![compu_image], image_resolutions: vec![image_dimensions_u] })
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
world.create_entity()
|
world.create_entity()// just a drawable
|
||||||
.with(Render { vertices: vec![] })// just a drawable
|
|
||||||
.with(Position { x: 0.0, y: 0.0, z: 0 })
|
.with(Position { x: 0.0, y: 0.0, z: 0 })
|
||||||
.with(Geometry { size_x: 300.0, size_y: 300.0, rotation: 0.0 })
|
.with(Geometry { size_x: 300.0, size_y: 300.0, rotation: 0.0 })
|
||||||
.with(Textures { textures: vec![funky_handle] })
|
.with(Textures { textures: vec![funky_handle] })
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
world.create_entity()
|
|
||||||
.with(Render { vertices: vec![] })
|
|
||||||
.with(Position { x: 900.0, y: 900.0, z: 0 })
|
|
||||||
.with(Geometry { size_x: 600.0, size_y: 600.0, rotation: 0.0 })
|
|
||||||
.with(Images { images: vec![compu_image], image_resolutions: vec![image_dimensions_u] })
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// call the run method for the following systems & deps
|
// call the run method for the following systems & deps
|
||||||
let mut dispatcher = DispatcherBuilder::new()
|
let mut dispatcher = DispatcherBuilder::new()
|
||||||
|
|||||||
@@ -31,15 +31,6 @@ impl Component for Geometry {
|
|||||||
type Storage = VecStorage<Self>;
|
type Storage = VecStorage<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct Render {
|
|
||||||
pub vertices: Vec<VertexTypeContainer>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Component for Render {
|
|
||||||
type Storage = VecStorage<Self>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Textures {
|
pub struct Textures {
|
||||||
pub textures: Vec<Arc<CanvasTextureHandle>>,
|
pub textures: Vec<Arc<CanvasTextureHandle>>,
|
||||||
@@ -63,7 +54,6 @@ pub struct RenderSystem;
|
|||||||
|
|
||||||
impl<'a> System<'a> for RenderSystem {
|
impl<'a> System<'a> for RenderSystem {
|
||||||
type SystemData = (
|
type SystemData = (
|
||||||
WriteStorage<'a, Render>,
|
|
||||||
WriteStorage<'a, Position>,
|
WriteStorage<'a, Position>,
|
||||||
WriteStorage<'a, Geometry>,
|
WriteStorage<'a, Geometry>,
|
||||||
WriteStorage<'a, Textures>,
|
WriteStorage<'a, Textures>,
|
||||||
@@ -73,7 +63,6 @@ impl<'a> System<'a> for RenderSystem {
|
|||||||
);
|
);
|
||||||
|
|
||||||
fn run(&mut self, (
|
fn run(&mut self, (
|
||||||
mut vertices_list,
|
|
||||||
mut pos_list,
|
mut pos_list,
|
||||||
mut geom_list,
|
mut geom_list,
|
||||||
mut textures_list,
|
mut textures_list,
|
||||||
@@ -86,7 +75,7 @@ impl<'a> System<'a> for RenderSystem {
|
|||||||
// 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());
|
||||||
|
|
||||||
for (vertices, position, geometry, textures) in (&mut vertices_list, &mut pos_list, &mut geom_list, &mut textures_list).join() {
|
for (position, geometry, textures) in (&mut pos_list, &mut geom_list, &mut textures_list).join() {
|
||||||
// geom.pos_x += mv.vel_x * state.delta_time;
|
// geom.pos_x += mv.vel_x * state.delta_time;
|
||||||
// geom.pos_y += mv.vel_y * state.delta_time;
|
// geom.pos_y += mv.vel_y * state.delta_time;
|
||||||
|
|
||||||
@@ -105,7 +94,7 @@ impl<'a> System<'a> for RenderSystem {
|
|||||||
state.canvas_frame.add(textured_vertices);
|
state.canvas_frame.add(textured_vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (vertices, position, geometry, images) in (&mut vertices_list, &mut pos_list, &mut geom_list, &mut images_list).join() {
|
for (position, geometry, images) in (&mut pos_list, &mut geom_list, &mut images_list).join() {
|
||||||
// geom.pos_x += mv.vel_x * state.delta_time;
|
// geom.pos_x += mv.vel_x * state.delta_time;
|
||||||
// geom.pos_y += mv.vel_y * state.delta_time;
|
// geom.pos_y += mv.vel_y * state.delta_time;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user