bevy/pipelined/bevy_sprite2/src/lib.rs

45 lines
1.4 KiB
Rust
Raw Normal View History

2021-04-11 20:13:07 +00:00
mod bundle;
mod rect;
mod render;
2021-04-11 20:13:07 +00:00
mod sprite;
pub use bundle::*;
2021-04-11 20:13:07 +00:00
pub use rect::*;
pub use render::*;
pub use sprite::*;
use bevy_app::prelude::*;
use bevy_ecs::prelude::IntoSystem;
use bevy_render2::{
2021-06-02 02:59:17 +00:00
core_pipeline, render_graph::RenderGraph, render_phase::DrawFunctions, RenderStage,
2021-04-11 20:13:07 +00:00
};
#[derive(Default)]
pub struct SpritePlugin;
impl Plugin for SpritePlugin {
fn build(&self, app: &mut App) {
app.register_type::<Sprite>();
let render_app = app.sub_app_mut(0);
render_app
.add_system_to_stage(RenderStage::Extract, render::extract_sprites.system())
.add_system_to_stage(RenderStage::Prepare, render::prepare_sprites.system())
.add_system_to_stage(RenderStage::Queue, queue_sprites.system())
.init_resource::<SpriteShaders>()
2021-06-02 02:59:17 +00:00
.init_resource::<SpriteMeta>();
2021-04-11 20:13:07 +00:00
let draw_sprite = DrawSprite::new(&mut render_app.world);
render_app
.world
.get_resource::<DrawFunctions>()
.unwrap()
2021-06-02 02:59:17 +00:00
.write()
2021-04-11 20:13:07 +00:00
.add(draw_sprite);
let render_world = app.sub_app_mut(0).world.cell();
let mut graph = render_world.get_resource_mut::<RenderGraph>().unwrap();
graph.add_node("sprite", SpriteNode);
graph
2021-06-02 02:59:17 +00:00
.add_node_edge("sprite", core_pipeline::node::MAIN_PASS_DEPENDENCIES)
2021-04-11 20:13:07 +00:00
.unwrap();
}
}