From c48b54f3fb7bbe9046915eb99eca02fa84dc55c9 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:22 +0100 Subject: feat(render): multithreaded texture loading also a bunch of supporting changes --- stockton-render/src/window.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'stockton-render/src/window.rs') diff --git a/stockton-render/src/window.rs b/stockton-render/src/window.rs index e6bd5b0..4a1628d 100644 --- a/stockton-render/src/window.rs +++ b/stockton-render/src/window.rs @@ -20,6 +20,7 @@ use egui::Context; use legion::systems::Runnable; use log::debug; use std::sync::Arc; +use stockton_levels::prelude::{MinBspFeatures, VulkanSystem}; use egui::{Output, PaintJobs, Pos2, RawInput, Ui}; @@ -86,7 +87,7 @@ impl WindowEvent { } } -pub struct UIState { +pub struct UiState { pub(crate) ctx: Arc, pub(crate) raw_input: RawInput, ui: Option, @@ -94,7 +95,7 @@ pub struct UIState { pub(crate) last_tex_ver: u64, } -impl UIState { +impl UiState { pub fn ui(&mut self) -> &mut Ui { if self.ui.is_none() { self.ui = Some(self.begin_frame()); @@ -144,8 +145,8 @@ impl UIState { } } - pub fn new(renderer: &Renderer) -> Self { - let mut state = UIState { + pub fn new>(renderer: &Renderer) -> Self { + let mut state = UiState { ctx: Context::new(), raw_input: RawInput::default(), ui: None, @@ -162,11 +163,14 @@ impl UIState { #[system] /// A system to process the window events sent to renderer by the winit event loop. -pub fn _process_window_events( - #[resource] renderer: &mut Renderer<'static>, +pub fn _process_window_events< + T: 'static + InputManager, + M: 'static + MinBspFeatures, +>( + #[resource] renderer: &mut Renderer<'static, M>, #[resource] manager: &mut T, #[resource] mouse: &mut Mouse, - #[resource] ui_state: &mut UIState, + #[resource] ui_state: &mut UiState, #[state] actions_buf: &mut Vec, ) { let mut actions_buf_cursor = 0; @@ -220,6 +224,9 @@ pub fn _process_window_events( manager.handle_frame(&actions_buf[0..actions_buf_cursor]); } -pub fn process_window_events_system() -> impl Runnable { - _process_window_events_system::(Vec::with_capacity(4)) +pub fn process_window_events_system< + T: 'static + InputManager, + M: 'static + MinBspFeatures, +>() -> impl Runnable { + _process_window_events_system::(Vec::with_capacity(4)) } -- cgit v1.2.3