Move texture loader in Resource

This commit is contained in:
Florian RICHER 2025-06-12 12:56:04 +02:00
parent 37467d5066
commit 6a0491fe51
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
3 changed files with 31 additions and 28 deletions

View file

@ -7,6 +7,7 @@ use crate::core::render::primitives::vulkan_resource::{
VulkanCommandBufferAllocator, VulkanComputeQueue, VulkanDescriptorSetAllocator, VulkanDevice,
VulkanGraphicsQueue, VulkanInstance, VulkanMemoryAllocator, VulkanTransferQueue,
};
use crate::core::render::resources::texture::TextureLoader;
use bevy_ecs::world::World;
use super::{AsScene, Scene};
@ -14,7 +15,6 @@ use super::{AsScene, Scene};
pub struct SceneManager {
scenes: Vec<Scene>,
current_scene_index: Option<usize>,
window_context: Option<Rc<RefCell<WindowContext>>>,
}
impl SceneManager {
@ -22,14 +22,9 @@ impl SceneManager {
Self {
scenes: Vec::new(),
current_scene_index: None,
window_context: None,
}
}
pub fn set_window_context(&mut self, window_context: Rc<RefCell<WindowContext>>) {
self.window_context = Some(window_context);
}
fn create_world_with_resources(window_context: &WindowContext) -> World {
let mut world = World::new();
@ -45,6 +40,13 @@ impl SceneManager {
let vulkan_command_buffer_allocator = vulkan_context.command_buffer_allocator();
let vulkan_descriptor_set_allocator = vulkan_context.descriptor_set_allocator();
let texture_loader = TextureLoader::new(
vulkan_device.clone(),
vulkan_command_buffer_allocator.clone(),
vulkan_memory_allocator.clone(),
TextureLoader::select_best_suitable_queue(vulkan_graphics_queue, vulkan_transfer_queue),
);
world.insert_resource(VulkanInstance(vulkan_instance.clone()));
world.insert_resource(VulkanDevice(vulkan_device.clone()));
world.insert_resource(VulkanGraphicsQueue(vulkan_graphics_queue.clone()));
@ -57,6 +59,7 @@ impl SceneManager {
world.insert_resource(VulkanDescriptorSetAllocator(
vulkan_descriptor_set_allocator.clone(),
));
world.insert_resource(texture_loader);
world
}