From 23711c46fbcf4c5be6c7d1e7e7272efd6cd51374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 1 Jul 2025 17:21:53 +0200 Subject: [PATCH] GL: don't cause a GL error in Context::shadingLanguageVersionStrings(). The llvmpipe on Ubuntu 18.04 is still just GL 3.3, which means using a GL 4.3 feature without any checks leads to a GL error. Don't. --- src/Magnum/GL/Context.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 6a8140e1b..ef02fc2c7 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -1122,13 +1122,13 @@ Containers::StringView Context::shadingLanguageVersionString() const { Containers::Array Context::shadingLanguageVersionStrings() const { #ifndef MAGNUM_TARGET_GLES - GLint versionCount = 0; - glGetIntegerv(GL_NUM_SHADING_LANGUAGE_VERSIONS, &versionCount); + /* GL_NUM_SHADING_LANGUAGE_VERSIONS is only since GL 4.3 */ + if(_version >= Version::GL430) { + GLint versionCount = 0; + glGetIntegerv(GL_NUM_SHADING_LANGUAGE_VERSIONS, &versionCount); + /* If on GL 4.3+, there should be always at least one */ + CORRADE_INTERNAL_ASSERT(versionCount); - /* If zero, the implementation doesn't yet support this query (< GL4.3) */ - /** @todo doesn't this throw a GL error? some better handling? */ - if(versionCount) { - /* Get all of them */ Containers::Array versions{std::size_t(versionCount)}; for(GLint i = 0; i != versionCount; ++i) versions[i] = {reinterpret_cast(glGetStringi(GL_SHADING_LANGUAGE_VERSION, i)), Containers::StringViewFlag::Global}; @@ -1136,6 +1136,7 @@ Containers::Array Context::shadingLanguageVersionStrings } #endif + /* On GLES or GL < 4.3 return just the main */ return Containers::array({shadingLanguageVersionString()}); }