[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.
This commit is contained in:
Martin Gräßlin 2015-11-02 10:43:48 +01:00
parent 4d6dbc63f6
commit 1170303fc6
2 changed files with 12 additions and 6 deletions

View file

@ -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 OpenGL<space>ES<space><version number><space><vendor-specific information>."
// 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()

View file

@ -373,6 +373,7 @@ private:
bool m_virtualMachine: 1;
bool m_preferBufferSubData: 1;
OpenGLPlatformInterface m_platformInterface;
bool m_gles: 1;
static GLPlatform *s_platform;
};