Skip to content

Commit

Permalink
Merge pull request #343 from waywardmonkeys/update-bevy-example
Browse files Browse the repository at this point in the history
with_bevy: Update to bevy 0.11 release.
  • Loading branch information
waywardmonkeys authored Jul 20, 2023
2 parents e84138b + 3b3d369 commit 6e9b5c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/with_bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { git = "https://github.com/bevyengine/bevy", rev = "4d54ce14aaee8d7432380df37c41c03c28594b27" }
bevy = "0.11"
vello = { path = "../../" }
14 changes: 9 additions & 5 deletions examples/with_bevy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct VelloRenderer(Renderer);

impl FromWorld for VelloRenderer {
fn from_world(world: &mut World) -> Self {
let device = world.get_resource::<RenderDevice>().unwrap();
let queue = world.get_resource::<RenderQueue>().unwrap();
let device = world.resource::<RenderDevice>();
let queue = world.resource::<RenderQueue>();

VelloRenderer(
Renderer::new(
Expand All @@ -42,10 +42,14 @@ struct VelloPlugin;
impl Plugin for VelloPlugin {
fn build(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
render_app.init_resource::<VelloRenderer>();
// This should probably use the render graph, but working out the dependencies there is awkward
render_app.add_systems(Render, render_scenes.in_set(RenderSet::Render));
}

fn finish(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
render_app.init_resource::<VelloRenderer>();
}
}

fn render_scenes(
Expand Down Expand Up @@ -78,11 +82,11 @@ fn render_scenes(
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(VelloPlugin)
.add_plugins(VelloPlugin)
.add_systems(Startup, setup)
.add_systems(Update, bevy::window::close_on_esc)
.add_systems(Update, cube_rotator_system)
.add_plugin(ExtractComponentPlugin::<VelloScene>::default())
.add_plugins(ExtractComponentPlugin::<VelloScene>::default())
.add_systems(Update, render_fragment)
.run()
}
Expand Down

0 comments on commit 6e9b5c0

Please sign in to comment.