Skip to content

Commit

Permalink
Provide better error message when missing a render backend (bevyengin…
Browse files Browse the repository at this point in the history
  • Loading branch information
MinerSebas authored and ostwilkens committed Jul 27, 2021
1 parent 6e9271b commit df5816c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions crates/bevy_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod wireframe;

use bevy_ecs::{
schedule::{ParallelSystemDescriptorCoercion, SystemStage},
system::{IntoExclusiveSystem, IntoSystem},
system::{IntoExclusiveSystem, IntoSystem, Res},
};
use bevy_transform::TransformSystem;
use draw::{OutsideFrustum, Visible};
Expand Down Expand Up @@ -52,7 +52,7 @@ use render_graph::{
base::{self, BaseRenderGraphConfig, MainPass},
RenderGraph,
};
use renderer::{AssetRenderResourceBindings, RenderResourceBindings};
use renderer::{AssetRenderResourceBindings, RenderResourceBindings, RenderResourceContext};
use shader::ShaderLoader;
#[cfg(feature = "hdr")]
use texture::HdrTextureLoader;
Expand Down Expand Up @@ -160,6 +160,10 @@ impl Plugin for RenderPlugin {
.init_resource::<RenderResourceBindings>()
.init_resource::<AssetRenderResourceBindings>()
.init_resource::<ActiveCameras>()
.add_startup_system_to_stage(
StartupStage::PreStartup,
check_for_render_resource_context.system(),
)
.add_system_to_stage(CoreStage::PreUpdate, draw::clear_draw_system.system())
.add_system_to_stage(
CoreStage::PostUpdate,
Expand Down Expand Up @@ -222,3 +226,11 @@ impl Plugin for RenderPlugin {
}
}
}

fn check_for_render_resource_context(context: Option<Res<Box<dyn RenderResourceContext>>>) {
if context.is_none() {
panic!(
"bevy_render couldn't find a render backend. Perhaps try adding the bevy_wgpu plugin!"
)
}
}

0 comments on commit df5816c

Please sign in to comment.