|
|
|
@ -39,7 +39,7 @@ use crate::drawables::rect::Rect;
|
|
|
|
|
use crate::drawables::slider::Slider;
|
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
|
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::timer::Timer;
|
|
|
|
|
use crate::util::tr_event::{TrEvent, TrEventExtension};
|
|
|
|
@ -54,6 +54,14 @@ pub mod canvas;
|
|
|
|
|
pub mod render_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)]
|
|
|
|
|
pub struct PersistentState {
|
|
|
|
@ -68,17 +76,21 @@ struct EventSystem;
|
|
|
|
|
|
|
|
|
|
impl<'a> System<'a> for EventSystem {
|
|
|
|
|
type SystemData = (
|
|
|
|
|
Entities<'a>,
|
|
|
|
|
WriteStorage<'a, Evented>,
|
|
|
|
|
Write<'a, PersistentState>,
|
|
|
|
|
Write<'a, VkProcessor>,
|
|
|
|
|
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() {
|
|
|
|
|
//hprof::start_frame();
|
|
|
|
|
//let g = hprof::enter("vulkan preload");
|
|
|
|
@ -140,7 +152,6 @@ pub fn main() {
|
|
|
|
|
processor.get_texture_handle(String::from("sfml.png")).unwrap();
|
|
|
|
|
|
|
|
|
|
let mut world = World::new();
|
|
|
|
|
world.register::<Render>();
|
|
|
|
|
world.register::<Compu>();
|
|
|
|
|
world.register::<Position>();
|
|
|
|
|
world.register::<Geometry>();
|
|
|
|
@ -156,25 +167,21 @@ pub fn main() {
|
|
|
|
|
compu_frame: CompuFrame::new((0, 0)),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// and the thing that renders it
|
|
|
|
|
world.create_entity()
|
|
|
|
|
.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(Images { images: vec![compu_image.clone()], image_resolutions: vec![image_dimensions_u] })
|
|
|
|
|
.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();
|
|
|
|
|
|
|
|
|
|
world.create_entity()
|
|
|
|
|
.with(Render { vertices: vec![] })// just a drawable
|
|
|
|
|
world.create_entity()// just a drawable
|
|
|
|
|
.with(Position { x: 0.0, y: 0.0, z: 0 })
|
|
|
|
|
.with(Geometry { size_x: 300.0, size_y: 300.0, rotation: 0.0 })
|
|
|
|
|
.with(Textures { textures: vec![funky_handle] })
|
|
|
|
|
.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
|
|
|
|
|
let mut dispatcher = DispatcherBuilder::new()
|
|
|
|
|