From 403ed25b1206496bd17e8201034d8e8cf3b3688f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 29 Apr 2020 13:19:49 +0200 Subject: [PATCH] GL: don't call GL3+ APIs on GL 2.1. Makes Zink sad. --- src/Magnum/GL/Context.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index fa3b13eeb..71a35b654 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -924,13 +924,17 @@ std::vector Context::shadingLanguageVersionStrings() const { std::vector Context::extensionStrings() const { std::vector extensions; + /* If we have GL 3.0 / GLES 3.0 at least, ask the new way. Otherwise don't + even attempt to query GL_NUM_EXTENSIONS as that would cause a GL error + on GL 2.1. Happens with Mesa's zink that's just 2.1 currently (Apr 2020) + even though for other backends Mesa exposes this. */ #ifndef MAGNUM_TARGET_GLES2 - GLint extensionCount = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount); #ifndef MAGNUM_TARGET_GLES3 - if(extensionCount || isVersionSupported(Version::GL300)) + if(isVersionSupported(Version::GL300)) #endif { + GLint extensionCount = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount); extensions.reserve(extensionCount); for(GLint i = 0; i != extensionCount; ++i) extensions.emplace_back(reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)));