kwin: Fix extension list query for core contexts

Use glGetStringi() to list the extensions when the GL version is 3.0
or greater. glGetString() does not accept the GL_EXTENSIONS token
in an OpenGL core context.
This commit is contained in:
Fredrik Höglund 2013-03-13 16:39:26 +01:00
parent 55a8e68a4c
commit 63e0d32706
2 changed files with 47 additions and 5 deletions

View file

@ -525,9 +525,6 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
m_renderer = (const char*)glGetString(GL_RENDERER);
m_version = (const char*)glGetString(GL_VERSION);
const QByteArray extensions = (const char*)glGetString(GL_EXTENSIONS);
m_extensions = QSet<QByteArray>::fromList(extensions.split(' '));
// Parse the OpenGL version
const QList<QByteArray> versionTokens = m_version.split(' ');
if (versionTokens.count() > 0) {
@ -535,6 +532,31 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface)
m_glVersion = parseVersionString(version);
}
#ifndef KWIN_HAVE_OPENGLES
if (m_glVersion >= kVersionNumber(3, 0)) {
PFNGLGETSTRINGIPROC glGetStringi;
#ifdef KWIN_HAVE_EGL
if (platformInterface == EglPlatformInterface)
glGetStringi = (PFNGLGETSTRINGIPROC) eglGetProcAddress("glGetStringi");
else
#endif
glGetStringi = (PFNGLGETSTRINGIPROC) glXGetProcAddress((const GLubyte *) "glGetStringi");
int count;
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
for (int i = 0; i < count; i++) {
const char *name = (const char *) glGetStringi(GL_EXTENSIONS, i);
m_extensions.insert(name);
}
} else
#endif
{
const QByteArray extensions = (const char *) glGetString(GL_EXTENSIONS);
m_extensions = QSet<QByteArray>::fromList(extensions.split(' '));
}
// Parse the Mesa version
const int mesaIndex = versionTokens.indexOf("Mesa");
if (mesaIndex != -1) {

View file

@ -102,11 +102,31 @@ void initGL(OpenGLPlatformInterface platformInterface)
QStringList glversioninfo = glversionstring.left(glversionstring.indexOf(' ')).split('.');
while (glversioninfo.count() < 3)
glversioninfo << "0";
#ifndef KWIN_HAVE_OPENGLES
glVersion = MAKE_GL_VERSION(glversioninfo[0].toInt(), glversioninfo[1].toInt(), glversioninfo[2].toInt());
#endif
// Get list of supported OpenGL extensions
glExtensions = QString((const char*)glGetString(GL_EXTENSIONS)).split(' ');
if (hasGLVersion(3, 0)) {
PFNGLGETSTRINGIPROC glGetStringi;
#ifdef KWIN_HAVE_EGL
if (platformInterface == EglPlatformInterface)
glGetStringi = (PFNGLGETSTRINGIPROC) eglGetProcAddress("glGetStringi");
else
#endif
glGetStringi = (PFNGLGETSTRINGIPROC) glXGetProcAddress((const GLubyte *) "glGetStringi");
int count;
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
for (int i = 0; i < count; i++) {
const char *name = (const char *) glGetStringi(GL_EXTENSIONS, i);
glExtensions << QString(name);
}
} else
#endif
glExtensions = QString((const char*)glGetString(GL_EXTENSIONS)).split(' ');
// handle OpenGL extensions functions
glResolveFunctions(platformInterface);