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::{WindowConfig, WindowPlugin},
20 },
21};
22
23pub mod pipeline;
24pub mod render;
25pub mod types;
26pub mod window;
27
28pub struct GraphicsPlugin {
33 features: DeviceFeatures,
34 window: WindowConfig,
35}
36
37impl GraphicsPlugin {
38 pub fn new() -> Self {
39 Self {
40 features: DeviceFeatures::empty(),
41 window: WindowConfig::default(),
42 }
43 }
44
45 pub fn with_features(features: DeviceFeatures) -> Self {
46 Self {
47 features,
48 window: WindowConfig::default(),
49 }
50 }
51
52 pub fn with_window(mut self, window: WindowConfig) -> Self {
56 self.window = window;
57 self
58 }
59}
60
61impl Plugin for GraphicsPlugin {
62 fn build(self, app: crate::app::App) -> crate::app::App {
63 app.add_plugin(WindowPlugin::new(self.window))
64 .add_plugin(BackendPlugin::with_features(self.features))
65 .add_plugin(BuiltinAssetsPlugin)
66 }
67}
68
69pub struct BuiltinAssetsPlugin;
73impl Plugin for BuiltinAssetsPlugin {
74 fn build(self, app: crate::app::App) -> crate::app::App {
75 app.insert_resource(GlobalLayoutPool::default())
76 .add_system(SystemStage::AssetSync, init_global_samplers)
77 .add_system(SystemStage::AssetSync, init_mipmap_generator)
78 .add_plugin(AssetPlugin::<Backend, Mesh>::new())
79 .add_plugin(AssetPlugin::<Backend, Texture>::new())
80 .add_plugin(AssetPlugin::<Backend, TextureArray>::new())
81 .add_plugin(AssetPlugin::<Backend, Cubemap>::new())
82 .add_plugin(AssetPlugin::<Backend, Material>::new())
83 .add_plugin(AssetPlugin::<Backend, Compute>::new())
84 .add_plugin(AssetPlugin::<Backend, MaterialInstance>::new())
85 .add_plugin(AssetPlugin::<Backend, ComputeInstance>::new())
86 }
87}
88
89#[cfg(test)]
90mod test {}