diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:22 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:22 +0100 |
commit | b688a25810840c5ebf4bf2c18bbdae52c62f6b4d (patch) | |
tree | 923c81d1be62d1344694306d5fb8728841620b6f /examples | |
parent | bf9573764c695e65b1504419fafb76ccabb0322b (diff) |
feat(render): WIP eGUI integration
Diffstat (limited to 'examples')
-rw-r--r-- | examples/render-bsp/Cargo.toml | 2 | ||||
-rw-r--r-- | examples/render-bsp/src/main.rs | 30 |
2 files changed, 28 insertions, 4 deletions
diff --git a/examples/render-bsp/Cargo.toml b/examples/render-bsp/Cargo.toml index 90f5ef9..bbcaf1d 100644 --- a/examples/render-bsp/Cargo.toml +++ b/examples/render-bsp/Cargo.toml @@ -15,3 +15,5 @@ winit = "^0.21" log = "0.4.0" simple_logger = "^1.11" image = "0.23.2" +egui = "^0.2" +legion = { version = "^0.3" } diff --git a/examples/render-bsp/src/main.rs b/examples/render-bsp/src/main.rs index 9332629..7622897 100644 --- a/examples/render-bsp/src/main.rs +++ b/examples/render-bsp/src/main.rs @@ -20,17 +20,21 @@ #[macro_use] extern crate stockton_input_codegen; +#[macro_use] +extern crate legion; + use std::collections::BTreeMap; use winit::{event::Event, event_loop::EventLoop, window::WindowBuilder}; use stockton_contrib::delta_time::*; use stockton_contrib::flycam::*; + use stockton_input::{Axis, InputManager, Mouse}; use stockton_levels::{prelude::*, q3::Q3BSPFile}; -use stockton_render::{ - do_render_system, draw::calc_vp_matrix_system, window::process_window_events_system, Renderer, - WindowEvent, -}; + +use stockton_render::systems::*; +use stockton_render::{Renderer, UIState, WindowEvent}; + use stockton_types::components::{CameraSettings, Transform}; use stockton_types::{Session, Vector3}; @@ -58,6 +62,21 @@ impl FlycamInput for MovementInputs { } } +#[system] +fn hello_world(#[resource] ui: &mut UIState, #[state] name: &mut String, #[state] age: &mut f32) { + let ui = ui.ui(); + ui.heading("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + // ui.horizontal(|ui| { + // ui.label("Your name: "); + // ui.text_edit(name); + // }); + // ui.add(egui::Slider::f32(age, 0.0..=120.0).text("age")); + // if ui.button("Click each year").clicked { + // *age += 1.0; + // } + // ui.label(format!("Hello '{}', age {}", name, age)); +} + fn main() { // Initialise logger simple_logger::SimpleLogger::new() @@ -107,6 +126,7 @@ fn main() { // Load everything into the session let mut session = Session::new( move |resources| { + resources.insert(UIState::new(&renderer)); resources.insert(renderer); resources.insert(bsp); resources.insert(manager); @@ -117,6 +137,8 @@ fn main() { schedule .add_system(update_deltatime_system()) .add_system(process_window_events_system::<MovementInputsManager>()) + .flush() + .add_system(hello_world_system("".to_string(), 0.0)) .add_system(flycam_move_system::<MovementInputsManager>()) .flush() .add_system(calc_vp_matrix_system()) |