From 8e1cc17bc59e3410315e42a7fe8e54f4afaae9ab Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 10 Jan 2025 16:22:08 +0100 Subject: can render multiple viewports --- client/src/state.rs | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'client/src/state.rs') diff --git a/client/src/state.rs b/client/src/state.rs index 70746d8..00a8c0b 100644 --- a/client/src/state.rs +++ b/client/src/state.rs @@ -14,15 +14,11 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -use crate::{ - camera::Camera, download::Downloader, network::Network, renderer::Renderer, ui::UiSurface, -}; +use crate::{camera::Camera, download::Downloader, network::Network, renderer::Renderer}; use anyhow::{Context, Result}; -use egui::ViewportId; use glam::{Vec2, Vec3}; use log::{info, warn}; -use rand::random; -use std::{net::TcpStream, sync::Arc, time::Instant}; +use std::{net::TcpStream, time::Instant}; use weareshared::{store::ResourceStore, tree::SceneTree}; use winit::event::MouseButton; @@ -72,21 +68,17 @@ impl<'a> State<'a> { if !down || button != MouseButton::Right { return; } - self.renderer.ui_renderer.surfaces.insert( - ViewportId::from_hash_of(random::()), - UiSurface { - transform: self.camera.new_ui_affine(), - content: Arc::new(|ctx| { - egui::Window::new("Funny window") - .default_open(true) - .show(ctx, |ui| { - ui.label("world space ui actually kinda works now"); - ui.label("Does input work?"); - ui.button("Yes").clicked(); - }); - }), - }, - ); + self.renderer + .ui_renderer + .add_surface(self.camera.new_ui_affine(), |ctx| { + egui::Window::new("Funny window") + .default_open(true) + .show(ctx, |ui| { + ui.label("world space ui actually kinda works now"); + ui.label("Does input work?"); + ui.button("Yes").clicked(); + }); + }); } pub fn update(&mut self) -> Result<()> { let now = Instant::now(); -- cgit v1.2.3-70-g09d2