1use crate::{
2 assets::plugin::AssetPlugin,
3 ecs::{plugin::Plugin, system::SystemStage},
4 graphics::{
5 pipeline::{
6 compute::Compute,
7 cubemap::Cubemap,
8 instance::{ComputeInstance, MaterialInstance},
9 layout::GlobalLayoutPool,
10 material::Material,
11 mesh::Mesh,
12 mipmap::init_mipmap_generator,
13 samplers::init_global_samplers,
14 texture_array::TextureArray,
15 textures::Texture,
16 },
17 render::{Backend, BackendPlugin},
18 types::flags::DeviceFeatures,
19 window::WindowPlugin,
20 },
21};
22
23pub mod pipeline;
24pub mod render;
25pub mod types;
26pub mod window;
27
28pub struct GraphicsPlugin {
33 features: DeviceFeatures,
34}
35
36impl GraphicsPlugin {
37 pub fn new() -> Self {
38 Self {
39 features: DeviceFeatures::empty(),
40 }
41 }
42
43 pub fn with_features(features: DeviceFeatures) -> Self {
44 Self { features }
45 }
46}
47
48impl Plugin for GraphicsPlugin {
49 fn build(self, app: crate::app::App) -> crate::app::App {
50 app.add_plugin(WindowPlugin::default())
51 .add_plugin(BackendPlugin::with_features(self.features))
52 .add_plugin(BuiltinAssetsPlugin)
53 }
54}
55
56pub struct BuiltinAssetsPlugin;
60impl Plugin for BuiltinAssetsPlugin {
61 fn build(self, app: crate::app::App) -> crate::app::App {
62 app.insert_resource(GlobalLayoutPool::default())
63 .add_system(SystemStage::AssetSync, init_global_samplers)
64 .add_system(SystemStage::AssetSync, init_mipmap_generator)
65 .add_plugin(AssetPlugin::<Backend, Mesh>::new())
66 .add_plugin(AssetPlugin::<Backend, Texture>::new())
67 .add_plugin(AssetPlugin::<Backend, TextureArray>::new())
68 .add_plugin(AssetPlugin::<Backend, Cubemap>::new())
69 .add_plugin(AssetPlugin::<Backend, Material>::new())
70 .add_plugin(AssetPlugin::<Backend, Compute>::new())
71 .add_plugin(AssetPlugin::<Backend, MaterialInstance>::new())
72 .add_plugin(AssetPlugin::<Backend, ComputeInstance>::new())
73 }
74}
75
76#[cfg(test)]
77mod test {}