Fix imgui renderer once and for all

Finally solved the problems with the imgui renderer after a long chat with clankers. Fixed some other stuff as well.

Reminder to keep the rendered_this_frame check as that's what solved it. Probably a deeper issue down there that caused us to render twice, but whatever.
This commit is contained in:
reo 2025-09-10 01:31:43 +03:00
parent 15122b8ebd
commit 0c0d5cdb2a
7 changed files with 77 additions and 51 deletions

View file

@ -15,3 +15,4 @@ raidillon_ecs = { path = "../ecs" }
raidillon_engine = { path = "../engine" }
raidillon_glium = { path = "../glium_platform", optional = true }
glam = "0.30.5"
winit = "0.30.12"

View file

@ -11,15 +11,39 @@ use raidillon_core::scene::Scene;
#[cfg(feature = "glium")]
use raidillon_glium::GliumPlatform;
use raidillon_core::DebugUIBuffer;
use winit::event::{Event, WindowEvent};
const TEST_GLTF: &str = "pink-monkey.gltf";
const RENDERING_TEST_SYSTEM: &str = "rendering_test_system";
const UPDATE_ASPECT_RATIO_SYSTEM: &str = "update_aspect_ratio_system";
const MAIN_SCENE_ID: &str = "main_scene";
struct RenderingTestSystem;
struct UpdateAspectRatioSystem;
impl System for UpdateAspectRatioSystem {
fn initialize(&mut self) {}
fn load_world(&mut self, ctx: &mut SystemContext) {}
fn update(&mut self, ctx: &mut SystemContext) {
// FIXME: Need an event handler rework for systems.
match &ctx.platform_context.current_event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::Resized(sz) => {
let _ = ctx.scene.world.query_mut::<&mut Camera>().into_iter().map(|mut cam| {
cam.1.aspect = sz.width as f32 / sz.height as f32;
});
}
_ => {}
},
_ => {}
}
}
}
struct RenderingTestSystem;
impl System for RenderingTestSystem {
fn initialize(&mut self) {}
fn load_world(&mut self, ctx: &mut SystemContext) {
@ -61,6 +85,7 @@ fn main() {
// engine.system_manager.add_system("spawn_chunks".to_string(), ChunkSystem);
// engine.system_manager.add_system("movement".to_string(), MovementSystem);
engine.system_manager.add_system(RENDERING_TEST_SYSTEM, Box::new(RenderingTestSystem));
engine.system_manager.add_system(UPDATE_ASPECT_RATIO_SYSTEM, Box::new(UpdateAspectRatioSystem));
// Set up the scene
let main_scene = Scene::new(