use std::{path::PathBuf, sync::Arc}; use anyhow::Result; use context::prelude::*; use ecs::*; pub struct SkyBoxImages { left: PathBuf, right: PathBuf, front: PathBuf, back: PathBuf, top: PathBuf, bottom: PathBuf, } impl> From for SkyBoxImages { fn from(mut paths: T) -> Self { debug_assert_eq!(paths.len(), 6); Self { left: paths.next().unwrap(), right: paths.next().unwrap(), front: paths.next().unwrap(), back: paths.next().unwrap(), top: paths.next().unwrap(), bottom: paths.next().unwrap(), } } } pub struct SkyBox { cube_map: Arc, } impl SkyBox { pub fn new(world: &mut WorldBuilder, images: impl Into) -> Result<()> { let images = images.into(); let context = world.resources.get_mut::(); context.render_core_mut().add_render_routine::(1); let cube_map = Image::cube_map([ images.left.try_into()?, images.right.try_into()?, images.front.try_into()?, images.back.try_into()?, images.top.try_into()?, images.bottom.try_into()?, ])? .format(VK_FORMAT_R8G8B8A8_UNORM) .max_mip_map_levels() .attach_pretty_sampler(context.device())? .build(context.device(), context.queue())?; let me = Self { cube_map }; world.resources.insert(me); Ok(()) } } impl TScene for SkyBox { fn process( &mut self, buffer_recorder: &mut CommandBufferRecorder<'_>, images: &TargetMode>>, indices: &TargetMode, world: &World, ) -> Result<()> { todo!() } fn resize( &mut self, window_width: f32, window_height: f32, images: &TargetMode>>, ) -> Result<()> { todo!() } }