render_plugin: Begin add window plugin

This commit is contained in:
Florian RICHER 2025-05-18 19:28:34 +02:00
parent 0ee29a3649
commit ae0a2be097
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
8 changed files with 134 additions and 48 deletions

View 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>();
}
}