render_plugin: Begin add window plugin
This commit is contained in:
parent
0ee29a3649
commit
ae0a2be097
8 changed files with 134 additions and 48 deletions
35
crates/engine_render/src/window/mod.rs
Normal file
35
crates/engine_render/src/window/mod.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use bevy_app::{App, Plugin};
|
||||
use bevy_ecs::resource::Resource;
|
||||
use vulkano::{
|
||||
image::view::ImageView, pipeline::graphics::viewport::Viewport, swapchain::Swapchain,
|
||||
sync::GpuFuture,
|
||||
};
|
||||
|
||||
use crate::RenderApp;
|
||||
|
||||
pub struct WindowSurfaceData {
|
||||
pub swapchain: Arc<Swapchain>,
|
||||
pub attachment_image_views: Vec<Arc<ImageView>>,
|
||||
pub viewport: Viewport,
|
||||
pub recreate_swapchain: bool,
|
||||
pub previous_frame_end: Option<Box<dyn GpuFuture + Send + Sync>>,
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct WindowSurface {
|
||||
pub surface: Option<WindowSurfaceData>,
|
||||
}
|
||||
|
||||
pub struct WindowRenderPlugin;
|
||||
|
||||
impl Plugin for WindowRenderPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
let render_app = app
|
||||
.get_sub_app_mut(RenderApp)
|
||||
.expect("Failed to get RenderApp. Check is RenderPlugin is added.");
|
||||
|
||||
render_app.init_resource::<WindowSurface>();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue