From 865698548f23fa13a03202442bf114f5c01b8f46 Mon Sep 17 00:00:00 2001 From: TheRawMeatball Date: Fri, 4 Feb 2022 21:22:12 +0000 Subject: [PATCH] Fix HDR asset support (#3795) The HDR texture loader was never added to the app, this PR makes sure it is added when the relevant feature is enabled. --- .../src/texture/image_texture_loader.rs | 15 ++++++++++++++- crates/bevy_render/src/texture/mod.rs | 14 +++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/texture/image_texture_loader.rs b/crates/bevy_render/src/texture/image_texture_loader.rs index 20e6c774cc..14848be25a 100644 --- a/crates/bevy_render/src/texture/image_texture_loader.rs +++ b/crates/bevy_render/src/texture/image_texture_loader.rs @@ -9,7 +9,20 @@ use crate::texture::{Image, ImageType, TextureError}; #[derive(Clone, Default)] pub struct ImageTextureLoader; -const FILE_EXTENSIONS: &[&str] = &["png", "dds", "tga", "jpg", "jpeg", "bmp"]; +const FILE_EXTENSIONS: &[&str] = &[ + #[cfg(feature = "png")] + "png", + #[cfg(feature = "dds")] + "dds", + #[cfg(feature = "tga")] + "tga", + #[cfg(feature = "jpeg")] + "jpg", + #[cfg(feature = "jpeg")] + "jpeg", + #[cfg(feature = "bmp")] + "bmp", +]; impl AssetLoader for ImageTextureLoader { fn load<'a>( diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index e6658195bf..fe53007baa 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -10,6 +10,7 @@ pub(crate) mod image_texture_conversion; pub use self::image::*; #[cfg(feature = "hdr")] pub use hdr_texture_loader::*; + pub use image_texture_loader::*; pub use texture_cache::*; @@ -23,11 +24,22 @@ pub struct ImagePlugin; impl Plugin for ImagePlugin { fn build(&self, app: &mut App) { - #[cfg(feature = "png")] + #[cfg(any( + feature = "png", + feature = "dds", + feature = "tga", + feature = "jpeg", + feature = "bmp" + ))] { app.init_asset_loader::(); } + #[cfg(feature = "hdr")] + { + app.init_asset_loader::(); + } + app.add_plugin(RenderAssetPlugin::::default()) .add_asset::(); app.world