From 2cf585905923fedd37f7297fc4c1acb9f546362a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 19:56:55 +0000 Subject: [PATCH 1/3] build(deps): update glium requirement from 0.27.0 to 0.33.0 Updates the requirements on [glium](https://github.com/glium/glium) to permit the latest version. - [Release notes](https://github.com/glium/glium/releases) - [Changelog](https://github.com/glium/glium/blob/master/CHANGELOG.md) - [Commits](https://github.com/glium/glium/compare/v0.27.0...v0.33.0) --- updated-dependencies: - dependency-name: glium dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9832faf..963a931 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ v4l-sys = { path = "v4l-sys", version = "0.3.0", optional = true } v4l2-sys = { path = "v4l2-sys", version = "0.3.0", package="v4l2-sys-mit", optional = true } [dev-dependencies] -glium = "0.27.0" +glium = "0.33.0" jpeg-decoder = "0.3.0" [features] From 52adb80bab5591a1fdb5161a16053b6aeb49345c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 2 Dec 2023 17:46:23 +0100 Subject: [PATCH 2/3] Make `glium` example compatible with latest `winit`-less `glutin` crate `glutin` detached itself from `winit` by using `raw-window-handle` for window interop, and a minimal `glutin-winit` crate for lightweight window creation and event handling where necessary. This also makes the `glutin` crate more generic to use, for non-windowing GL cases. --- Cargo.toml | 3 ++- examples/glium.rs | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 963a931..7a7d714 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,9 @@ v4l-sys = { path = "v4l-sys", version = "0.3.0", optional = true } v4l2-sys = { path = "v4l2-sys", version = "0.3.0", package="v4l2-sys-mit", optional = true } [dev-dependencies] -glium = "0.33.0" +glium = "0.33" jpeg-decoder = "0.3.0" +winit = "0.28" [features] default = ["v4l2"] diff --git a/examples/glium.rs b/examples/glium.rs index 381e82e..e6c691f 100644 --- a/examples/glium.rs +++ b/examples/glium.rs @@ -4,7 +4,7 @@ use std::thread; use std::time::Instant; use glium::index::PrimitiveType; -use glium::{glutin, Surface}; +use glium::Surface; use glium::{implement_vertex, program, uniform}; use jpeg_decoder as jpeg; @@ -54,10 +54,8 @@ fn main() -> io::Result<()> { println!("Active parameters:\n{}", params); // Setup the GL display stuff - let event_loop = glutin::event_loop::EventLoop::new(); - let wb = glutin::window::WindowBuilder::new(); - let cb = glutin::ContextBuilder::new().with_vsync(true); - let display = glium::Display::new(wb, cb, &event_loop).unwrap(); + let event_loop = winit::event_loop::EventLoop::new(); + let (_window, display) = glium::backend::glutin::SimpleWindowBuilder::new().build(&event_loop); // building the vertex buffer, which contains all the vertices that we will draw let vertex_buffer = { @@ -183,12 +181,12 @@ fn main() -> io::Result<()> { target.finish().unwrap(); // polling and handling the events received by the window - if let glutin::event::Event::WindowEvent { - event: glutin::event::WindowEvent::CloseRequested, + if let winit::event::Event::WindowEvent { + event: winit::event::WindowEvent::CloseRequested, .. } = event { - *control_flow = glutin::event_loop::ControlFlow::Exit; + *control_flow = winit::event_loop::ControlFlow::Exit; } print!( From d72437bba0b4d5725058b2223f682b10d36b18b0 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 9 Jan 2024 09:41:14 +0100 Subject: [PATCH 3/3] Upgrade `glium` example to `winit 0.29` and `glium 0.34` --- Cargo.toml | 4 +- examples/glium.rs | 102 ++++++++++++++++++++++++---------------------- 2 files changed, 55 insertions(+), 51 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7a7d714..3ebcec3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,9 @@ v4l-sys = { path = "v4l-sys", version = "0.3.0", optional = true } v4l2-sys = { path = "v4l2-sys", version = "0.3.0", package="v4l2-sys-mit", optional = true } [dev-dependencies] -glium = "0.33" +glium = "0.34" jpeg-decoder = "0.3.0" -winit = "0.28" +winit = "0.29" [features] default = ["v4l2"] diff --git a/examples/glium.rs b/examples/glium.rs index e6c691f..c14f6a3 100644 --- a/examples/glium.rs +++ b/examples/glium.rs @@ -54,7 +54,7 @@ fn main() -> io::Result<()> { println!("Active parameters:\n{}", params); // Setup the GL display stuff - let event_loop = winit::event_loop::EventLoop::new(); + let event_loop = winit::event_loop::EventLoop::new().map_err(io::Error::other)?; let (_window, display) = glium::backend::glutin::SimpleWindowBuilder::new().build(&event_loop); // building the vertex buffer, which contains all the vertices that we will draw @@ -146,53 +146,57 @@ fn main() -> io::Result<()> { } }); - event_loop.run(move |event, _, control_flow| { - let t0 = Instant::now(); - let data = rx.recv().unwrap(); - let t1 = Instant::now(); - - let image = - glium::texture::RawImage2d::from_raw_rgb_reversed(&data, (format.width, format.height)); - let opengl_texture = glium::texture::Texture2d::new(&display, image).unwrap(); - - // building the uniforms - let uniforms = uniform! { - matrix: [ - [1.0, 0.0, 0.0, 0.0], - [0.0, 1.0, 0.0, 0.0], - [0.0, 0.0, 1.0, 0.0], - [0.0, 0.0, 0.0, 1.0f32] - ], - tex: &opengl_texture - }; - - // drawing a frame - let mut target = display.draw(); - target.clear_color(0.0, 0.0, 0.0, 0.0); - target - .draw( - &vertex_buffer, - &index_buffer, - &program, - &uniforms, - &Default::default(), - ) - .unwrap(); - target.finish().unwrap(); - - // polling and handling the events received by the window - if let winit::event::Event::WindowEvent { - event: winit::event::WindowEvent::CloseRequested, - .. - } = event - { - *control_flow = winit::event_loop::ControlFlow::Exit; - } + event_loop + .run(move |event, elwt| { + let t0 = Instant::now(); + let data = rx.recv().unwrap(); + let t1 = Instant::now(); + + let image = glium::texture::RawImage2d::from_raw_rgb_reversed( + &data, + (format.width, format.height), + ); + let opengl_texture = glium::texture::Texture2d::new(&display, image).unwrap(); + + // building the uniforms + let uniforms = uniform! { + matrix: [ + [1.0, 0.0, 0.0, 0.0], + [0.0, 1.0, 0.0, 0.0], + [0.0, 0.0, 1.0, 0.0], + [0.0, 0.0, 0.0, 1.0f32] + ], + tex: &opengl_texture + }; - print!( - "\rms: {}\t (buffer) + {}\t (UI)", - t1.duration_since(t0).as_millis(), - t0.elapsed().as_millis() - ); - }); + // drawing a frame + let mut target = display.draw(); + target.clear_color(0.0, 0.0, 0.0, 0.0); + target + .draw( + &vertex_buffer, + &index_buffer, + &program, + &uniforms, + &Default::default(), + ) + .unwrap(); + target.finish().unwrap(); + + // polling and handling the events received by the window + if let winit::event::Event::WindowEvent { + event: winit::event::WindowEvent::CloseRequested, + .. + } = event + { + elwt.exit(); + } + + print!( + "\rms: {}\t (buffer) + {}\t (UI)", + t1.duration_since(t0).as_millis(), + t0.elapsed().as_millis() + ); + }) + .map_err(io::Error::other) }