From 8159e074271642200ff9e85c384bd3fe1d84b025 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 28 Jul 2021 20:31:22 -0500 Subject: [PATCH] Ensure our GL context is always current --- app/streaming/video/ffmpeg-renderers/eglvid.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/eglvid.cpp b/app/streaming/video/ffmpeg-renderers/eglvid.cpp index b40245f6..ccc3277d 100644 --- a/app/streaming/video/ffmpeg-renderers/eglvid.cpp +++ b/app/streaming/video/ffmpeg-renderers/eglvid.cpp @@ -696,9 +696,6 @@ const float *EGLRenderer::getColorMatrix() { bool EGLRenderer::specialize() { SDL_assert(!m_VAO); - // Attach our GL context to the render thread - SDL_GL_MakeCurrent(m_Window, m_Context); - if (!compileShaders()) return false; @@ -760,6 +757,12 @@ void EGLRenderer::renderFrame(AVFrame* frame) return; } + // Attach our GL context to the render thread + // NB: It should already be current, unless the SDL render event watcher + // performs a rendering operation (like a viewport update on resize) on + // our fake SDL_Renderer. If it's already current, this is a no-op. + SDL_GL_MakeCurrent(m_Window, m_Context); + // Find the native read-back format and load the shaders if (m_EGLImagePixelFormat == AV_PIX_FMT_NONE) { m_EGLImagePixelFormat = m_Backend->getEGLImagePixelFormat();