bevy/crates/bevy_render/src/lib.rs

103 lines
3.2 KiB
Rust
Raw Normal View History

2020-04-06 22:54:17 +00:00
#![feature(min_specialization)]
2020-04-28 00:41:02 +00:00
pub mod batch;
2020-03-14 19:56:37 +00:00
mod camera;
2020-04-06 23:15:59 +00:00
pub mod entity;
2020-03-14 19:56:37 +00:00
pub mod mesh;
2020-02-18 02:36:31 +00:00
pub mod render_graph;
pub mod renderer;
2020-04-04 19:43:16 +00:00
pub mod shader;
pub mod vertex;
2020-01-08 06:35:07 +00:00
mod color;
2019-12-01 09:16:15 +00:00
2020-01-11 10:11:27 +00:00
pub use camera::*;
2020-02-22 23:02:01 +00:00
pub use color::*;
2020-04-04 19:43:16 +00:00
pub use renderable::*;
2020-01-11 19:29:57 +00:00
pub use vertex::Vertex;
2020-01-01 20:23:39 +00:00
pub mod base_render_graph;
2020-03-10 06:08:09 +00:00
pub mod draw_target;
pub mod pass;
pub mod pipeline;
pub mod render_resource;
mod renderable;
2020-03-20 19:47:33 +00:00
pub mod texture;
2020-04-05 21:12:14 +00:00
2020-04-06 03:19:02 +00:00
pub use once_cell;
2020-04-05 21:12:14 +00:00
use self::{
2020-04-06 23:15:59 +00:00
mesh::Mesh,
2020-04-05 21:12:14 +00:00
pipeline::{
PipelineAssignments, PipelineCompiler, PipelineDescriptor, VertexBufferDescriptors,
2020-04-05 21:12:14 +00:00
},
render_resource::{
2020-04-28 00:41:02 +00:00
entity_render_resource_assignments_system, EntityRenderResourceAssignments,
RenderResourceAssignments,
2020-04-05 21:12:14 +00:00
},
shader::Shader,
2020-04-06 23:15:59 +00:00
texture::Texture,
2020-04-05 21:12:14 +00:00
};
use base_render_graph::{BaseRenderGraphBuilder, BaseRenderGraphConfig};
use bevy_app::{stage, AppBuilder, AppPlugin};
2020-05-13 23:17:44 +00:00
use bevy_asset::AddAsset;
2020-05-16 07:27:30 +00:00
use legion::prelude::IntoSystem;
use mesh::mesh_resource_provider_system;
use render_graph::RenderGraph;
2020-05-16 02:30:02 +00:00
use render_resource::EntitiesWaitingForAssets;
use texture::{PngTextureLoader, TextureResourceSystemState};
2020-04-05 21:12:14 +00:00
pub static RENDER_RESOURCE_STAGE: &str = "render_resource";
2020-04-06 08:57:00 +00:00
pub static RENDER_STAGE: &str = "render";
pub struct RenderPlugin {
/// configures the "base render graph". If this is not `None`, the "base render graph" will be added
pub base_render_graph_config: Option<BaseRenderGraphConfig>,
}
2020-04-05 21:12:14 +00:00
impl Default for RenderPlugin {
fn default() -> Self {
RenderPlugin {
base_render_graph_config: Some(BaseRenderGraphConfig::default()),
}
}
}
2020-04-05 21:12:14 +00:00
impl AppPlugin for RenderPlugin {
2020-04-06 03:19:02 +00:00
fn build(&self, app: &mut AppBuilder) {
app.add_stage_after(bevy_asset::stage::ASSET_EVENTS, RENDER_RESOURCE_STAGE)
.add_stage_after(RENDER_RESOURCE_STAGE, RENDER_STAGE)
2020-05-13 23:17:44 +00:00
.add_asset::<Mesh>()
.add_asset::<Texture>()
.add_asset::<Shader>()
.add_asset::<PipelineDescriptor>()
2020-05-16 02:30:02 +00:00
.add_asset_loader(PngTextureLoader::default())
.init_resource::<RenderGraph>()
2020-05-13 23:35:38 +00:00
.init_resource::<PipelineAssignments>()
.init_resource::<PipelineCompiler>()
.init_resource::<RenderResourceAssignments>()
.init_resource::<VertexBufferDescriptors>()
.init_resource::<EntityRenderResourceAssignments>()
2020-05-16 02:30:02 +00:00
.init_resource::<EntitiesWaitingForAssets>()
.init_resource::<TextureResourceSystemState>()
.add_system(entity_render_resource_assignments_system())
2020-05-01 20:12:47 +00:00
.init_system_to_stage(stage::POST_UPDATE, camera::camera_update_system)
2020-05-16 07:27:30 +00:00
.add_system_to_stage(
stage::PRE_UPDATE,
EntitiesWaitingForAssets::clear_system.system(),
)
.init_system_to_stage(RENDER_RESOURCE_STAGE, mesh_resource_provider_system)
.add_system_to_stage(
RENDER_RESOURCE_STAGE,
Texture::texture_resource_system.system(),
);
if let Some(ref config) = self.base_render_graph_config {
let resources = app.resources();
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
render_graph.add_base_graph(resources, config);
}
2020-04-05 21:12:14 +00:00
}
}