From 5851b43ca65d979b2d290eb94bd0187f9b9e5736 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:23 +0100 Subject: chore(render-quad): add textures --- stockton-render/src/draw/draw_passes/level.rs | 18 +++++++++++------- stockton-render/src/draw/draw_passes/mod.rs | 2 +- stockton-render/src/draw/mod.rs | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'stockton-render/src') diff --git a/stockton-render/src/draw/draw_passes/level.rs b/stockton-render/src/draw/draw_passes/level.rs index 9872b8c..682c775 100644 --- a/stockton-render/src/draw/draw_passes/level.rs +++ b/stockton-render/src/draw/draw_passes/level.rs @@ -17,7 +17,7 @@ use crate::{ }, queue_negotiator::QueueNegotiator, target::SwapchainProperties, - texture::{resolver::FsResolver, TexLoadQueue, TextureLoadConfig, TextureRepo}, + texture::{resolver::TextureResolver, TexLoadQueue, TextureLoadConfig, TextureRepo}, }, error::{EnvironmentError, LevelError, LockPoisoned}, types::*, @@ -52,7 +52,6 @@ use std::{ convert::TryInto, iter::{empty, once}, marker::PhantomData, - path::Path, sync::{Arc, RwLock}, }; @@ -264,13 +263,19 @@ where } } -impl<'a, M> IntoDrawPass> for Entity +pub struct LevelDrawPassConfig { + pub active_camera: Entity, + pub tex_resolver: R, +} + +impl<'a, M, R> IntoDrawPass> for LevelDrawPassConfig where M: for<'b> MinRenderFeatures<'b> + 'static, + R: TextureResolver + Send + Sync + 'static, { fn init( self, - session: &Session, + _session: &Session, adapter: &Adapter, device_lock: Arc>, queue_negotiator: &mut QueueNegotiator, @@ -356,7 +361,6 @@ where .build() .context("Error building pipeline")?; - let map_lock: Arc> = session.resources.get::>>().unwrap().clone(); let repo = TextureRepo::new( device_lock.clone(), queue_negotiator @@ -369,7 +373,7 @@ where .context("Error finding texture queue")?, adapter, TextureLoadConfig { - resolver: FsResolver::new(Path::new("textures"), map_lock), + resolver: self.tex_resolver, filter: Filter::Linear, wrap_mode: WrapMode::Tile, }, @@ -434,7 +438,7 @@ where pipeline, repo, draw_buffers, - active_camera: self, + active_camera: self.active_camera, _d: PhantomData, framebuffers, depth_buffers, diff --git a/stockton-render/src/draw/draw_passes/mod.rs b/stockton-render/src/draw/draw_passes/mod.rs index b18d50e..8d1d59b 100644 --- a/stockton-render/src/draw/draw_passes/mod.rs +++ b/stockton-render/src/draw/draw_passes/mod.rs @@ -13,7 +13,7 @@ mod ui; pub mod util; pub use cons::ConsDrawPass; -pub use level::LevelDrawPass; +pub use level::{LevelDrawPass, LevelDrawPassConfig}; pub use ui::UiDrawPass; /// One of several 'passes' that draw on each frame. diff --git a/stockton-render/src/draw/mod.rs b/stockton-render/src/draw/mod.rs index b570b12..4ba38cd 100644 --- a/stockton-render/src/draw/mod.rs +++ b/stockton-render/src/draw/mod.rs @@ -8,7 +8,7 @@ pub mod camera; mod context; pub mod draw_passes; mod queue_negotiator; -mod texture; +pub mod texture; mod ui; mod utils; -- cgit v1.2.3