egui support

- New Resource, EguiQueue: Utility to queue egui ui builders
- New Rendering System, EguiRenderer: Utilizes a modified egui_glium
  library to render egui UI
- Adjusted RenderingSystem trait and RenderingContext structure to
  provide event_loop and egui_queue.
- Various minor adjusments
This commit is contained in:
reo 2025-11-16 18:14:12 +03:00
parent e88ce258ce
commit ce24354f3b
18 changed files with 806 additions and 204 deletions

22
core/src/egui_queue.rs Normal file
View file

@ -0,0 +1,22 @@
pub struct EguiQueue {
pub queue_vec: Vec<Box<dyn FnOnce(&egui::Context) + Send>>,
}
impl EguiQueue {
pub fn new() -> Self {
Self { queue_vec: Vec::new() }
}
pub fn queue(&mut self, func: impl FnOnce(&egui::Context) + Send + 'static) {
self.queue_vec.push(Box::new(func));
}
pub fn clear(&mut self) {
self.queue_vec.clear()
}
pub fn run(&mut self, ctx: &egui::Context) {
self.queue_vec.drain(..).for_each(|func| func(ctx));
self.clear();
}
}

View file

@ -1,5 +1,3 @@
use std::cell::RefCell;
use std::rc::Rc;
use crate::DebugUIBuffer;
use crate::scene::Scene;
@ -14,5 +12,4 @@ pub trait EngineTrait {
fn current_scene(&self) -> &Scene;
fn get_debug_ui_buffer(&self) -> &DebugUIBuffer;
fn reset_debug_ui_buffer(&mut self);
// fn scene_and_debug_ui_buffer_mut(&mut self) -> (&mut Self::Scene, &DebugUIBuffer);
}

View file

@ -3,5 +3,7 @@ pub mod debug_ui;
pub mod time;
pub mod utils;
pub mod scene;
mod egui_queue;
pub use debug_ui::*;
pub use egui_queue::EguiQueue;