First vulkan init working

This commit is contained in:
Florian RICHER 2025-05-18 12:41:25 +02:00
parent 6639f0bb1e
commit 99be029ff8
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
4 changed files with 36 additions and 28 deletions

View file

@ -1,7 +1,9 @@
use vulkan_context::VulkanContext;
use window_render_context::WindowRenderContext;
use bevy_app::App;
use bevy_app::{App, Plugin};
use super::window::raw_handle::WindowWrapper;
mod utils;
mod vulkan_context;
@ -13,16 +15,20 @@ pub enum VulkanError {
FailedToCreateVulkanContext,
}
pub struct Vulkan;
pub struct VulkanPlugin;
impl Vulkan {
pub fn new(app: &mut App) -> Result<(), VulkanError> {
impl Plugin for VulkanPlugin {
fn build(&self, app: &mut App) {
let vulkan_context = VulkanContext::from(app as &App);
app.world_mut().insert_resource(vulkan_context);
}
fn ready(&self, app: &App) -> bool {
app.world().get_resource::<WindowWrapper>().is_some()
}
fn finish(&self, app: &mut App) {
let window_render_context = WindowRenderContext::from(app as &App);
app.world_mut().insert_resource(window_render_context);
Ok(())
}
}