Created
August 5, 2026 19:21
-
-
Save edg-l/8d11743eece13769a328656cd0fac9ab to your computer and use it in GitHub Desktop.
ddnet #12467: EGL backend GL version negotiation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/engine/client/backend_egl.cpp b/src/engine/client/backend_egl.cpp | |
| index 2d942a405..906487bc1 100644 | |
| --- a/src/engine/client/backend_egl.cpp | |
| +++ b/src/engine/client/backend_egl.cpp | |
| @@ -432,6 +432,7 @@ int CGraphicsBackend_EGL::InitOpenGL(int Width, int Height, int Flags, IStorage | |
| } | |
| int InitError = 0; | |
| + const char *pErrorStr = nullptr; | |
| { | |
| CCommandProcessorFragment_GLBase::SCommand_Init CmdGL; | |
| CmdGL.m_pWindow = nullptr; | |
| @@ -446,13 +447,13 @@ int CGraphicsBackend_EGL::InitOpenGL(int Width, int Height, int Flags, IStorage | |
| CmdGL.m_pStorage = pStorage; | |
| CmdGL.m_pCapabilities = &m_Capabilities; | |
| CmdGL.m_pInitError = &InitError; | |
| - CmdGL.m_RequestedMajor = GlewMajor; | |
| - CmdGL.m_RequestedMinor = GlewMinor; | |
| - CmdGL.m_RequestedPatch = GlewPatch; | |
| + CmdGL.m_RequestedMajor = g_Config.m_GfxGLMajor; | |
| + CmdGL.m_RequestedMinor = g_Config.m_GfxGLMinor; | |
| + CmdGL.m_RequestedPatch = g_Config.m_GfxGLPatch; | |
| CmdGL.m_GlewMajor = GlewMajor; | |
| CmdGL.m_GlewMinor = GlewMinor; | |
| CmdGL.m_GlewPatch = GlewPatch; | |
| - CmdGL.m_pErrStringPtr = nullptr; | |
| + CmdGL.m_pErrStringPtr = &pErrorStr; | |
| CmdGL.m_pVendorString = m_aVendorString; | |
| CmdGL.m_pVersionString = m_aVersionString; | |
| CmdGL.m_pRendererString = m_aRendererString; | |
| @@ -477,10 +478,43 @@ int CGraphicsBackend_EGL::InitOpenGL(int Width, int Height, int Flags, IStorage | |
| WaitForIdle(); | |
| CmdBuffer.Reset(); | |
| } | |
| + | |
| + CCommandProcessorFragment_EGL::SCommand_Shutdown CmdEGL; | |
| + CmdBuffer.AddCommandUnsafe(CmdEGL); | |
| + RunBuffer(&CmdBuffer); | |
| + WaitForIdle(); | |
| + CmdBuffer.Reset(); | |
| + | |
| + CCommandProcessorFragment_GLBase::SCommand_PostShutdown CmdPost; | |
| + CmdBuffer.AddCommandUnsafe(CmdPost); | |
| + RunBufferSingleThreadedUnsafe(&CmdBuffer); | |
| + CmdBuffer.Reset(); | |
| + | |
| StopProcessor(); | |
| delete m_pProcessor; | |
| m_pProcessor = nullptr; | |
| - return -1; | |
| + | |
| + eglDestroyContext(m_Display, m_Context); | |
| + eglDestroySurface(m_Display, m_Surface); | |
| + eglTerminate(m_Display); | |
| + m_Display = nullptr; | |
| + m_Context = nullptr; | |
| + m_Surface = nullptr; | |
| + | |
| + // try setting to version string's supported version | |
| + if(InitError == -2) | |
| + { | |
| + g_Config.m_GfxGLMajor = m_Capabilities.m_ContextMajor; | |
| + g_Config.m_GfxGLMinor = m_Capabilities.m_ContextMinor; | |
| + g_Config.m_GfxGLPatch = m_Capabilities.m_ContextPatch; | |
| + } | |
| + | |
| + if(pErrorStr != nullptr) | |
| + { | |
| + str_copy(m_aErrorString, pErrorStr); | |
| + } | |
| + | |
| + return EGraphicsBackendErrorCodes::GRAPHICS_BACKEND_ERROR_CODE_GL_VERSION_FAILED; | |
| } | |
| // Viewport update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment