Fix compilation when png or hdr features are disabled

This commit is contained in:
caelunshun 2020-08-11 00:49:17 -06:00
parent a694d9a1b6
commit 58be36a09a
No known key found for this signature in database
GPG key ID: EC60409E5A0D4ECC
2 changed files with 18 additions and 3 deletions

View file

@ -45,7 +45,11 @@ use render_graph::{
}; };
use renderer::{AssetRenderResourceBindings, RenderResourceBindings}; use renderer::{AssetRenderResourceBindings, RenderResourceBindings};
use std::ops::Range; use std::ops::Range;
use texture::{HdrTextureLoader, ImageTextureLoader, TextureResourceSystemState}; #[cfg(feature = "hdr")]
use texture::HdrTextureLoader;
#[cfg(feature = "png")]
use texture::ImageTextureLoader;
use texture::TextureResourceSystemState;
/// The names of "render" App stages /// The names of "render" App stages
pub mod stage { pub mod stage {
@ -75,6 +79,15 @@ impl Default for RenderPlugin {
impl Plugin for RenderPlugin { impl Plugin for RenderPlugin {
fn build(&self, app: &mut AppBuilder) { fn build(&self, app: &mut AppBuilder) {
#[cfg(feature = "png")]
{
app.add_asset_loader::<Texture, ImageTextureLoader>();
}
#[cfg(feature = "hdr")]
{
app.add_asset_loader::<Texture, HdrTextureLoader>();
}
app.add_stage_after(bevy_asset::stage::ASSET_EVENTS, stage::RENDER_RESOURCE) app.add_stage_after(bevy_asset::stage::ASSET_EVENTS, stage::RENDER_RESOURCE)
.add_stage_after(stage::RENDER_RESOURCE, stage::RENDER_GRAPH_SYSTEMS) .add_stage_after(stage::RENDER_RESOURCE, stage::RENDER_GRAPH_SYSTEMS)
.add_stage_after(stage::RENDER_GRAPH_SYSTEMS, stage::DRAW) .add_stage_after(stage::RENDER_GRAPH_SYSTEMS, stage::DRAW)
@ -84,8 +97,6 @@ impl Plugin for RenderPlugin {
.add_asset::<Texture>() .add_asset::<Texture>()
.add_asset::<Shader>() .add_asset::<Shader>()
.add_asset::<PipelineDescriptor>() .add_asset::<PipelineDescriptor>()
.add_asset_loader::<Texture, HdrTextureLoader>()
.add_asset_loader::<Texture, ImageTextureLoader>()
.register_component::<Camera>() .register_component::<Camera>()
.register_component::<Draw>() .register_component::<Draw>()
.register_component::<RenderPipelines>() .register_component::<RenderPipelines>()

View file

@ -1,11 +1,15 @@
#[cfg(feature = "hdr")]
mod hdr_texture_loader; mod hdr_texture_loader;
#[cfg(feature = "png")]
mod image_texture_loader; mod image_texture_loader;
mod sampler_descriptor; mod sampler_descriptor;
mod texture; mod texture;
mod texture_descriptor; mod texture_descriptor;
mod texture_dimension; mod texture_dimension;
#[cfg(feature = "hdr")]
pub use hdr_texture_loader::*; pub use hdr_texture_loader::*;
#[cfg(feature = "png")]
pub use image_texture_loader::*; pub use image_texture_loader::*;
pub use sampler_descriptor::*; pub use sampler_descriptor::*;
pub use texture::*; pub use texture::*;