From: Bernie Innocenti Date: Mon, 1 Nov 2021 04:43:45 +0000 (-0700) Subject: Fix benchmarks for latest glium/glutin API X-Git-Url: https://codewiz.org/gitweb?p=mandelwow.git;a=commitdiff_plain;h=HEAD;hp=1c9185a391b011d8d700f34a4d70cf770ac9e71f;ds=sidebyside Fix benchmarks for latest glium/glutin API --- diff --git a/Cargo.toml b/Cargo.toml index c360bb2..4143b23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,9 @@ opt-level = 3 [dependencies] cgmath = "*" #gleam = "*" -glium = "0.29" -glutin = "0.26" -winit = { version = "0.24", features = ["web-sys"] } +glium = "0.30" +glutin = "0.27" +winit = { version = "0.25", features = ["web-sys"] } image = { version = "*", features = ["png_codec"], optional = true } instant = { version = "0.1", features = ["wasm-bindgen"] } libxm = "1.0.0" diff --git a/benches/bounding_box.rs b/benches/bounding_box.rs index 54351d9..7187354 100644 --- a/benches/bounding_box.rs +++ b/benches/bounding_box.rs @@ -4,17 +4,18 @@ extern crate test; use glium::uniform; use mandelwow_lib::Cube; use mandelwow_lib::bounding_box::*; +use std::rc::Rc; #[bench] fn bench_bounding_box(b: &mut test::Bencher) { - let events_loop = glium::glutin::EventsLoop::new(); - let window = glium::glutin::WindowBuilder::new(); - let context = glium::glutin::ContextBuilder::new(); - let display = glium::Display::new(window, context, &events_loop).unwrap(); + let event_loop = glutin::event_loop::EventLoop::new(); + let window = glutin::window::WindowBuilder::new(); + let context = glutin::ContextBuilder::new(); + let display = glium::Display::new(window, context, &event_loop).unwrap(); - let program = solid_fill_program(&display); + let program = Rc::new(solid_fill_program(&display)); let bounds = Cube { xmin: -2., xmax: 0.7, ymin: -1., ymax: 1., zmin: -1.1, zmax: 1.1 }; - let bbox = BoundingBox::new(&display, &bounds, &program); + let bbox = BoundingBox::new(&display, &bounds, program); let mut frame = display.draw(); b.iter(|| { let mat = [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.0f32]]; diff --git a/benches/shaded_cube.rs b/benches/shaded_cube.rs index 842e290..6c51ab2 100644 --- a/benches/shaded_cube.rs +++ b/benches/shaded_cube.rs @@ -3,16 +3,17 @@ extern crate test; use glium::uniform; use mandelwow_lib::shaded_cube::*; +use std::rc::Rc; #[bench] fn bench_shaded_cube(b: &mut test::Bencher) { - let events_loop = glium::glutin::EventsLoop::new(); - let window = glium::glutin::WindowBuilder::new(); - let context = glium::glutin::ContextBuilder::new(); - let display = glium::Display::new(window, context, &events_loop).unwrap(); + let event_loop = glutin::event_loop::EventLoop::new(); + let window = glutin::window::WindowBuilder::new(); + let context = glutin::ContextBuilder::new(); + let display = glium::Display::new(window, context, &event_loop).unwrap(); - let program = shaded_program(&display); - let cube = ShadedCube::new(&display, &program); + let program = Rc::new(shaded_program(&display)); + let cube = ShadedCube::new(&display, program); let mut frame = display.draw(); b.iter(|| { let model = [[0.7, 0.5, -0.5, 0.0], [0.0, 0.7, 0.7, 0.0], [0.7, -0.5, 0.5, 0.0], [0., 0., -3.0, 1.0f32]]; diff --git a/rust-rocket b/rust-rocket index 3ca2cab..006eaf1 160000 --- a/rust-rocket +++ b/rust-rocket @@ -1 +1 @@ -Subproject commit 3ca2caba4878c73bfa4d2d7a36c2f3b943f9888a +Subproject commit 006eaf1463af595aa11113b5e4f407e3223a40df diff --git a/timer.rs b/timer.rs index 9f4abe0..9345838 100644 --- a/timer.rs +++ b/timer.rs @@ -4,7 +4,7 @@ use std::time::{Duration, Instant}; use rust_rocket; #[cfg(feature = "editor")] -type Rocket = rust_rocket::Rocket; +type Rocket = rust_rocket::client::RocketClient; #[cfg(not(feature = "editor"))] type Rocket = (); @@ -100,17 +100,19 @@ impl Timer { #[cfg(feature = "editor")] fn poll_rocket(&mut self) { + use rust_rocket::client::Event; + match self.rocket { Some(ref mut rocket) => { let current_row = (self.t * BPS) as u32; - if let Some(event) = rocket.poll_events() { + if let Some(event) = rocket.poll_events().unwrap() { match event { - rust_rocket::Event::SetRow(row) => { + Event::SetRow(row) => { println!("SetRow (row: {:?})", row); self.t = row as f32 / BPS; } - rust_rocket::Event::Pause(_) => { - let track1 = rocket.get_track_mut("test"); + Event::Pause(_) => { + let track1 = rocket.get_track_mut("test").unwrap(); println!("Pause (value: {:?}) (row: {:?})", track1.get_value(current_row as f32), current_row); } _ => (),