Skip to content

Commit

Permalink
Fix HDR asset support (#3795)
Browse files Browse the repository at this point in the history
The HDR texture loader was never added to the app, this PR makes sure it is added when the relevant feature is enabled.
  • Loading branch information
TheRawMeatball committed Feb 4, 2022
1 parent 3431335 commit 8656985
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
15 changes: 14 additions & 1 deletion crates/bevy_render/src/texture/image_texture_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
14 changes: 13 additions & 1 deletion crates/bevy_render/src/texture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand All @@ -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::<ImageTextureLoader>();
}

#[cfg(feature = "hdr")]
{
app.init_asset_loader::<HdrTextureLoader>();
}

app.add_plugin(RenderAssetPlugin::<Image>::default())
.add_asset::<Image>();
app.world
Expand Down

0 comments on commit 8656985

Please sign in to comment.