From 1170303fc6ee6878826340ac6a74001db6c87825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 2 Nov 2015 10:43:48 +0100 Subject: [PATCH] [kwineffects] Runtime detect whether we are on GLES in GLPlatform We detect from OpenGL version string whether we are on OpenGL ES instead of using a compile time check. --- libkwineffects/kwinglplatform.cpp | 17 +++++++++++------ libkwineffects/kwinglplatform.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libkwineffects/kwinglplatform.cpp b/libkwineffects/kwinglplatform.cpp index 6a60e5e1a5..ba1d4c2a2e 100644 --- a/libkwineffects/kwinglplatform.cpp +++ b/libkwineffects/kwinglplatform.cpp @@ -510,7 +510,8 @@ GLPlatform::GLPlatform() m_textureNPOT(false), m_limitedNPOT(false), m_virtualMachine(false), - m_platformInterface(NoOpenGLPlatformInterface) + m_platformInterface(NoOpenGLPlatformInterface), + m_gles(false) { } @@ -531,6 +532,14 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) if (versionTokens.count() > 0) { const QByteArray version = QByteArray(m_version); m_glVersion = parseVersionString(version); + if (platformInterface == EglPlatformInterface) { + // only EGL can have OpenGLES, GLX is OpenGL only + if (version.startsWith("OpenGL ES")) { + // from GLES 2: "Returns a version or release number of the form OpenGLES." + // from GLES 3: "Returns a version or release number." and "The version number uses one of these forms: major_number.minor_number major_number.minor_number.release_number" + m_gles = true; + } + } } #ifndef KWIN_HAVE_OPENGLES @@ -1049,11 +1058,7 @@ OpenGLPlatformInterface GLPlatform::platformInterface() const bool GLPlatform::isGLES() const { -#ifdef KWIN_HAVE_OPENGLES - return true; -#else - return false; -#endif + return m_gles; } void GLPlatform::cleanup() diff --git a/libkwineffects/kwinglplatform.h b/libkwineffects/kwinglplatform.h index 1885898ff5..0e96be911f 100644 --- a/libkwineffects/kwinglplatform.h +++ b/libkwineffects/kwinglplatform.h @@ -373,6 +373,7 @@ private: bool m_virtualMachine: 1; bool m_preferBufferSubData: 1; OpenGLPlatformInterface m_platformInterface; + bool m_gles: 1; static GLPlatform *s_platform; };