Ensure our GL context is always current

This commit is contained in:
Cameron Gutman 2021-07-28 20:31:22 -05:00
parent c658daeac6
commit 8159e07427

View File

@ -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();