Move texture loader in Resource
This commit is contained in:
parent
37467d5066
commit
6a0491fe51
3 changed files with 31 additions and 28 deletions
src/game/scenes
|
@ -42,7 +42,6 @@ pub struct Square;
|
|||
pub struct Cube;
|
||||
|
||||
pub struct MainSceneState {
|
||||
texture_loader: TextureLoader,
|
||||
pipeline_loader: PipelineLoader,
|
||||
square: SquareMesh,
|
||||
obj: ObjMesh,
|
||||
|
@ -81,7 +80,7 @@ impl AsScene for MainScene {
|
|||
pipeline_loader.register::<SimplePipeline>()?;
|
||||
pipeline_loader.load_pending_pipelines()?;
|
||||
|
||||
let mut texture_loader = TextureLoader::new(world);
|
||||
let mut texture_loader = world.resource_mut::<TextureLoader>();
|
||||
texture_loader.add_texture(
|
||||
"wooden-crate".to_string(),
|
||||
TextureLoadInfo {
|
||||
|
@ -143,7 +142,6 @@ impl AsScene for MainScene {
|
|||
camera,
|
||||
speed: 50.0,
|
||||
scheduler,
|
||||
texture_loader,
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
@ -258,6 +256,8 @@ impl AsScene for MainScene {
|
|||
&cube_transforms,
|
||||
)?;
|
||||
|
||||
let texture_loader = world.resource::<TextureLoader>();
|
||||
|
||||
state
|
||||
.pipeline_loader
|
||||
.with_pipeline::<SimplePipeline, _>(|pipeline| {
|
||||
|
@ -269,11 +269,7 @@ impl AsScene for MainScene {
|
|||
&square_transform_uniform,
|
||||
vec![
|
||||
camera_uniform.clone() as Arc<dyn AsDescriptorSet>,
|
||||
state
|
||||
.texture_loader
|
||||
.get_texture("wooden-crate")
|
||||
.unwrap()
|
||||
.clone(),
|
||||
texture_loader.get_texture("wooden-crate").unwrap().clone(),
|
||||
],
|
||||
)?;
|
||||
|
||||
|
@ -285,11 +281,7 @@ impl AsScene for MainScene {
|
|||
&cube_transform_uniform,
|
||||
vec![
|
||||
camera_uniform.clone() as Arc<dyn AsDescriptorSet>,
|
||||
state
|
||||
.texture_loader
|
||||
.get_texture("cube-diffuse")
|
||||
.unwrap()
|
||||
.clone(),
|
||||
texture_loader.get_texture("cube-diffuse").unwrap().clone(),
|
||||
],
|
||||
)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue