Compare commits

..

2 commits

Author SHA1 Message Date
0f8100ab53 Update Rust crate openvr to 0.7.0 2025-02-27 21:02:32 +00:00
b90a81bcc5 Fix close event 2025-02-27 19:25:40 +01:00
3 changed files with 29 additions and 12 deletions

View file

@ -14,13 +14,13 @@ pub struct WorldBuilder {
pub(crate) updates: Updates,
pub events: Events,
pub resources: Resources,
systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>,
systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>,
}
impl WorldBuilder {
pub fn add_system<F>(&mut self, f: F)
where
F: Fn(&mut World) -> Result<()> + Send + Sync + 'static,
F: Fn(&mut World) -> Result<bool> + Send + Sync + 'static,
{
self.systems.push(Box::new(f));
}
@ -66,7 +66,7 @@ pub struct World {
start_time: Instant,
systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>,
systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>,
}
impl World {
@ -349,7 +349,9 @@ impl World {
self.commit_entity_changes()?;
for system in systems.iter() {
system(self)?;
if !system(self)? {
return Ok(());
}
}
}
}

View file

@ -207,6 +207,15 @@ impl Engine {
world.resources.insert(engine);
world.resources.insert(engine_settings);
let scene = Scene::new(
create_info.rasterizer_info,
create_info.raytracing_info,
create_info.graphics_info,
world,
)?;
world.resources.insert(scene);
world.add_system(Self::main_system);
Ok(())
@ -247,10 +256,13 @@ impl Engine {
pub fn build_path(&self, path: &str) -> AssetPath {
(self.resource_base_path.as_str(), path).into()
}
}
pub fn main_system(world: &mut World) -> Result<()> {
//
Ok(())
impl Engine {
fn main_system(world: &mut World) -> Result<bool> {
world
.resources
.get_mut_unchecked::<Context>()
.next_frame::<()>(world)
}
}

View file

@ -55,15 +55,18 @@ pub struct Scene {
impl Scene {
pub(crate) fn new(
device: &Arc<Device>,
queue: &Arc<Mutex<Queue>>,
(screen_width, screen_height): (f32, f32),
images: &TargetMode<Vec<Arc<Image>>>,
rasterizer_info: RasterizerInfo,
raytracer_info: RaytracingInfo,
graphics_info: GraphicsInfo,
world: &mut WorldBuilder,
) -> Result<()> {
let context = world.resources.get::<Context>();
let device = context.device();
let queue = context.queue();
let (screen_width, screen_height) = (context.width() as f32, context.height() as f32);
let images = &context.images();
let (renderer, render_type): (Box<dyn RenderingFrontEnd + Send + Sync>, SceneType) =
Self::create_rendering_front_end(
device,