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

View file

@ -19,3 +19,4 @@ glam = "0.30.5"
winit = "0.30.12"
rapier3d = "0.30.1"
hecs = "0.10.5"
egui = "0.33.2"

View file

@ -16,7 +16,7 @@ use raidillon_glium::GliumPlatform;
use winit::event::{ElementState, Event, WindowEvent};
use winit::event::DeviceEvent::MouseMotion;
use winit::keyboard::{KeyCode, PhysicalKey};
use raidillon_core::DebugUIBuffer;
use raidillon_core::{DebugUIBuffer, EguiQueue};
use systems::debug_camera::FPSDebugCameraSystem;
use raidillon_glium::RenderingSystem;
use raidillon_physics::Physics;
@ -102,18 +102,30 @@ impl System for RenderingTestSystem {
}
fn frame_update(&mut self, res: &mut EngineResources, scene: &mut Scene) {
let pctx = res.get::<PlatformContext>().unwrap();
let input = res.get::<InputState>().unwrap();
let dbg_ui = scene.resources.get_mut::<DebugUIBuffer>().unwrap();
dbg_ui.text("Hello World!".to_owned());
dbg_ui.text(format!("Frame Delta: {}", pctx.time_ctx.frame_dt));
dbg_ui.text(format!("Fixed Delta: {}", pctx.time_ctx.fixed_dt));
dbg_ui.text(format!("FPS: {}", 1.0 / pctx.time_ctx.frame_dt));
let (
pctx,
input,
) = res.get_many_mut::<(
PlatformContext,
InputState,
)>().unwrap();
let mut egui_queue = pctx.egui_queue.borrow_mut();
let time_ctx = pctx.time_ctx.clone();
let mut character_pos = Vec3::ZERO;
for (_ent, (tr, ch_component)) in scene.world.query::<(&Transform, &CharacterBodyComponent)>().iter() {
dbg_ui.text(format!("Character POS: {}", tr.translation));
character_pos = tr.translation;
}
egui_queue.queue(move |egui_ctx| {
egui::Window::new("Debug").show(egui_ctx, |ui| {
ui.label("Hello World!");
ui.label(format!("Frame Delta: {}", time_ctx.frame_dt));
ui.label(format!("Fixed Delta: {}", time_ctx.fixed_dt));
ui.label(format!("FPS: {}", 1.0 / time_ctx.frame_dt));
ui.label(format!("Character POS: {}", character_pos));
});
});
}
}