diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 991c8705..7ed6315d 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -146,7 +146,7 @@ async fn run_instance( mut runtime: Runtime, A::Message>, mut debug: Debug, mut receiver: mpsc::UnboundedReceiver>, - context: glutin::ContextWrapper, + mut context: glutin::ContextWrapper, exit_on_close_request: bool, ) where A: Application + 'static, @@ -255,6 +255,16 @@ async fn run_instance( } event::Event::RedrawRequested(_) => { debug.render_started(); + + #[allow(unsafe_code)] + unsafe { + if !context.is_current() { + context = context + .make_current() + .expect("Make OpenGL context current"); + } + } + let current_viewport_version = state.viewport_version(); if viewport_version != current_viewport_version {