diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
commit | 6eb9083b1f2fec63e17dc8ef462ea89bae0854b5 (patch) | |
tree | 814f670c38040c37408db06b66c9cb24550393e9 /examples/render-quad/src/main.rs | |
parent | 6ef351de4ba506e7f0f285569aa0e22255bb68c6 (diff) |
feat(render): ui draw pass
Diffstat (limited to 'examples/render-quad/src/main.rs')
-rw-r--r-- | examples/render-quad/src/main.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/render-quad/src/main.rs b/examples/render-quad/src/main.rs index b16c3d0..681c2a1 100644 --- a/examples/render-quad/src/main.rs +++ b/examples/render-quad/src/main.rs @@ -13,7 +13,7 @@ use std::collections::BTreeMap; use std::sync::{Arc, RwLock}; use stockton_levels::parts::data::{Geometry, Vertex}; use stockton_levels::types::Rgba; -use stockton_render::draw::LevelDrawPass; +use stockton_render::draw::{ConsDrawPass, LevelDrawPass, UiDrawPass}; use winit::{event::Event, event_loop::EventLoop, window::WindowBuilder}; use egui::{containers::CentralPanel, Frame}; @@ -32,7 +32,7 @@ use stockton_types::{Session, Vector2, Vector3}; mod level; use level::*; -type Dp<'a> = LevelDrawPass<'a, DemoLevel>; +type Dp<'a> = ConsDrawPass<LevelDrawPass<'a, DemoLevel>, UiDrawPass<'a>>; #[derive(InputManager, Default, Clone, Debug)] struct MovementInputs { @@ -127,7 +127,7 @@ fn try_main<'a>() -> Result<()> { })); // Create the UI State - let mut ui = UiState::new(); + let ui = UiState::new(); // Create the input manager let manager = { @@ -155,6 +155,7 @@ fn try_main<'a>() -> Result<()> { resources.insert(manager); resources.insert(Timing::default()); resources.insert(Mouse::default()); + resources.insert(ui); }, move |schedule| { schedule @@ -187,14 +188,17 @@ fn try_main<'a>() -> Result<()> { )); // Create the renderer - let (renderer, tx): (Renderer<Dp<'static>>, _) = Renderer::new(&window, &session, player)?; + let (renderer, tx): (Renderer<Dp<'static>>, _) = + Renderer::new(&window, &session, (player, ()))?; let new_control_flow = renderer.update_control_flow.clone(); // Populate the initial UI state - ui.populate_initial_state(&renderer); + { + let ui = &mut session.resources.get_mut::<UiState>().unwrap(); + ui.populate_initial_state(&renderer); + } session.resources.insert(renderer); - session.resources.insert(ui); // Done loading - This is our main loop. // It just communicates events to the session and continuously ticks |