bevy/src/render/mod.rs

102 lines
3.6 KiB
Rust
Raw Normal View History

2020-03-14 19:56:37 +00:00
mod camera;
pub mod mesh;
2020-02-18 02:36:31 +00:00
pub mod render_graph;
2020-04-04 19:43:16 +00:00
pub mod shader;
2020-01-08 06:35:07 +00:00
mod color;
2019-12-02 04:03:04 +00:00
mod light;
2020-01-11 19:29:57 +00:00
mod vertex;
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::*;
2019-12-02 04:03:04 +00:00
pub use light::*;
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
2020-03-10 06:08:09 +00:00
pub mod draw_target;
pub mod pass;
pub mod pipeline;
pub mod render_resource;
mod renderable;
pub mod renderer;
2020-03-20 19:47:33 +00:00
pub mod texture;
2020-04-05 21:12:14 +00:00
use self::{
draw_target::draw_targets::{
AssignedBatchesDrawTarget, AssignedMeshesDrawTarget, MeshesDrawTarget, UiDrawTarget,
},
pass::passes::ForwardPassBuilder,
pipeline::{
pipelines::ForwardPipelineBuilder, PipelineCompiler, ShaderPipelineAssignments,
VertexBufferDescriptors,
},
render_graph::RenderGraph,
render_resource::{
build_entity_render_resource_assignments_system,
resource_providers::{
Camera2dResourceProvider, CameraResourceProvider, LightResourceProvider,
MeshResourceProvider, UiResourceProvider,
},
AssetBatchers, EntityRenderResourceAssignments, RenderResourceAssignments,
},
};
use crate::{prelude::*, window::WindowResized};
#[derive(Default)]
pub struct RenderPlugin;
impl RenderPlugin {
pub fn setup_render_graph_defaults(app: &mut AppBuilder) {
let mut pipelines = app
.resources
.get_mut::<AssetStorage<PipelineDescriptor>>()
.unwrap();
let mut shaders = app.resources.get_mut::<AssetStorage<Shader>>().unwrap();
let mut render_graph = app.resources.get_mut::<RenderGraph>().unwrap();
render_graph
.build(&mut pipelines, &mut shaders)
.add_draw_target(MeshesDrawTarget::default())
.add_draw_target(AssignedBatchesDrawTarget::default())
.add_draw_target(AssignedMeshesDrawTarget::default())
.add_draw_target(UiDrawTarget::default())
.add_resource_provider(CameraResourceProvider::new(
app.resources.get_event_reader::<WindowResized>(),
))
.add_resource_provider(Camera2dResourceProvider::new(
app.resources.get_event_reader::<WindowResized>(),
))
.add_resource_provider(LightResourceProvider::new(10))
.add_resource_provider(UiResourceProvider::new())
.add_resource_provider(MeshResourceProvider::new())
.add_resource_provider(UniformResourceProvider::<StandardMaterial>::new(true))
.add_resource_provider(UniformResourceProvider::<LocalToWorld>::new(true))
.add_forward_pass()
.add_forward_pipeline();
}
}
impl AppPlugin for RenderPlugin {
fn build(&self, mut app: AppBuilder) -> AppBuilder {
let mut asset_batchers = AssetBatchers::default();
asset_batchers.batch_types2::<Mesh, StandardMaterial>();
app = app
.add_system(build_entity_render_resource_assignments_system())
.add_resource(RenderGraph::default())
.add_resource(AssetStorage::<Mesh>::new())
.add_resource(AssetStorage::<Texture>::new())
.add_resource(AssetStorage::<Shader>::new())
.add_resource(AssetStorage::<StandardMaterial>::new())
.add_resource(AssetStorage::<PipelineDescriptor>::new())
.add_resource(ShaderPipelineAssignments::new())
.add_resource(VertexBufferDescriptors::default())
.add_resource(PipelineCompiler::new())
.add_resource(RenderResourceAssignments::default())
.add_resource(EntityRenderResourceAssignments::default())
.add_resource(asset_batchers);
RenderPlugin::setup_render_graph_defaults(&mut app);
app
}
}