examples/glupload: Fix build with glutin API changes

This commit is contained in:
Sebastian Dröge 2019-03-12 08:27:50 +01:00
parent e0c0c7d417
commit 811e8c1dba

View file

@ -329,7 +329,7 @@ struct App {
appsink: gst_app::AppSink, appsink: gst_app::AppSink,
bus: gst::Bus, bus: gst::Bus,
events_loop: Arc<glutin::EventsLoop>, events_loop: Arc<glutin::EventsLoop>,
combined_context: Arc<glutin::WindowedContext>, windowed_context: Arc<glutin::WindowedContext>,
} }
impl App { impl App {
@ -343,14 +343,14 @@ impl App {
let events_loop = glutin::EventsLoop::new(); let events_loop = glutin::EventsLoop::new();
let window = glutin::WindowBuilder::new().with_title("GL rendering"); let window = glutin::WindowBuilder::new().with_title("GL rendering");
let combined_context = Arc::new( let windowed_context = Arc::new(
glutin::ContextBuilder::new() glutin::ContextBuilder::new()
.with_vsync(true) .with_vsync(true)
.build_combined(window, &events_loop)?, .build_windowed(window, &events_loop)?,
); );
let combined_context_ = combined_context.clone(); let windowed_context_ = windowed_context.clone();
let context = combined_context_.context(); let context = windowed_context_.context();
if cfg!(target_os = "linux") { if cfg!(target_os = "linux") {
use glutin::os::unix::RawHandle; use glutin::os::unix::RawHandle;
@ -417,7 +417,7 @@ impl App {
appsink, appsink,
bus, bus,
events_loop: Arc::new(events_loop), events_loop: Arc::new(events_loop),
combined_context, windowed_context,
}) })
} }
@ -540,29 +540,29 @@ impl App {
} }
fn main_loop(mut app: App) -> Result<(), Error> { fn main_loop(mut app: App) -> Result<(), Error> {
unsafe { app.combined_context.make_current()? }; unsafe { app.windowed_context.make_current()? };
println!( println!(
"Pixel format of the window's GL context {:?}", "Pixel format of the window's GL context {:?}",
app.combined_context.get_pixel_format() app.windowed_context.get_pixel_format()
); );
let gl = load(&app.combined_context.context()); let gl = load(&app.windowed_context.context());
let (bus_handler, receiver) = app.setup()?; let (bus_handler, receiver) = app.setup()?;
let mut curr_frame: Option<Arc<gst_video::VideoFrame<gst_video::video_frame::Readable>>> = None; let mut curr_frame: Option<Arc<gst_video::VideoFrame<gst_video::video_frame::Readable>>> = None;
let mut running = true; let mut running = true;
let events_loop = Arc::get_mut(&mut app.events_loop).unwrap(); let events_loop = Arc::get_mut(&mut app.events_loop).unwrap();
let combined_context = app.combined_context.clone(); let windowed_context = app.windowed_context.clone();
while running { while running {
#[allow(clippy::single_match)] #[allow(clippy::single_match)]
events_loop.poll_events(|event| match event { events_loop.poll_events(|event| match event {
glutin::Event::WindowEvent { event, .. } => match event { glutin::Event::WindowEvent { event, .. } => match event {
glutin::WindowEvent::CloseRequested => running = false, glutin::WindowEvent::CloseRequested => running = false,
glutin::WindowEvent::Resized(logical_size) => { glutin::WindowEvent::Resized(logical_size) => {
let dpi_factor = combined_context.get_hidpi_factor(); let dpi_factor = windowed_context.get_hidpi_factor();
combined_context.resize(logical_size.to_physical(dpi_factor)); windowed_context.resize(logical_size.to_physical(dpi_factor));
gl.resize(logical_size.to_physical(dpi_factor)); gl.resize(logical_size.to_physical(dpi_factor));
} }
_ => (), _ => (),
@ -587,7 +587,7 @@ fn main_loop(mut app: App) -> Result<(), Error> {
gl.draw_frame(texture as gl::types::GLuint); gl.draw_frame(texture as gl::types::GLuint);
} }
} }
app.combined_context.swap_buffers()?; app.windowed_context.swap_buffers()?;
} }
app.pipeline.send_event(gst::Event::new_eos().build()); app.pipeline.send_event(gst::Event::new_eos().build());