From 68559411fc5cd5b175e0a6a339317797cda2dc07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 29 Apr 2020 13:35:30 +0200 Subject: [PATCH] Platform: drop the forward compatible flag for fallback GLX 2.1 context. Same is already done in the GLFW and SDL2 app. Also updated the comments to clarify why is it done (instead of an "I have no idea" TODO). --- src/Magnum/Platform/GlfwApplication.cpp | 4 +++- src/Magnum/Platform/Sdl2Application.cpp | 4 +++- src/Magnum/Platform/WindowlessGlxApplication.cpp | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 9ffd0e0f7..cfe74d164 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -527,7 +527,9 @@ bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConf glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); - /** @todo or keep the fwcompat? */ + /* Discard the ForwardCompatible flag for the fallback. Having it set + makes the fallback context creation fail on Mesa's Zink (which is + just 2.1) and I assume on others as well. */ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, false); _window = glfwCreateWindow(scaledWindowSize.x(), scaledWindowSize.y(), configuration.title().c_str(), monitor, nullptr); diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index b0e2f0e11..e65b5aa2b 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -572,7 +572,9 @@ bool Sdl2Application::tryCreate(const Configuration& configuration, const GLConf SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); - /** @todo or keep the fwcompat? */ + /* Discard the ForwardCompatible flag for the fallback. Having it set + makes the fallback context creation fail on Mesa's Zink (which is + just 2.1) and I assume on others as well. */ SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, int(glFlags) & int(~GLConfiguration::Flag::ForwardCompatible)); if(!(_window = SDL_CreateWindow(configuration.title().data(), diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index adccf2ae9..56db047a8 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -149,7 +149,10 @@ WindowlessGlxContext::WindowlessGlxContext(const WindowlessGlxContext::Configura } const GLint fallbackContextAttributes[] = { - GLX_CONTEXT_FLAGS_ARB, GLint(flags), + /* Discard the ForwardCompatible flag for the fallback. Having it + set makes the fallback context creation fail on Mesa's Zink + (which is just 2.1) and I assume on others as well. */ + GLX_CONTEXT_FLAGS_ARB, GLint(flags & ~Configuration::Flag::ForwardCompatible), 0 }; { @@ -188,7 +191,10 @@ WindowlessGlxContext::WindowlessGlxContext(const WindowlessGlxContext::Configura /* Destroy the core context and create a compatibility one */ glXDestroyContext(_display, _context); const GLint fallbackContextAttributes[] = { - /** @todo keep the fwcompat? */ + /* Discard the ForwardCompatible flag for the fallback. + Compared to the above case of a 2.1 fallback it's not really + needed here (AFAIK it works in both cases), but let's be + consistent. */ GLX_CONTEXT_FLAGS_ARB, GLint(flags & ~Configuration::Flag::ForwardCompatible), 0 };