Adding an initEGL method and check for required extension

icc-effect-5.14.5
Martin Gräßlin 2010-12-05 11:55:19 +01:00 committed by Martin Gräßlin
parent d12c4e58fd
commit 70fefbbbae
3 changed files with 33 additions and 2 deletions

View File

@ -48,9 +48,12 @@ namespace KWin
static int glVersion;
// GLX version, use MAKE_GL_VERSION() macro for comparing with a specific version
static int glXVersion;
// List of all supported GL and GLX extensions
// EGL version, use MAKE_GL_VERSION() macro for comparing with a specific version
static int eglVersion;
// List of all supported GL, EGL and GLX extensions
static QStringList glExtensions;
static QStringList glxExtensions;
static QStringList eglExtension;
int glTextureUnitsCount;
@ -71,6 +74,17 @@ void initGLX()
#endif
}
void initEGL()
{
#ifdef KWIN_HAVE_OPENGLES
EGLDisplay dpy = eglGetCurrentDisplay();
int major, minor;
eglInitialize(dpy, &major, &minor);
eglVersion = MAKE_GL_VERSION(major, minor, 0);
eglExtension = QString((const char*)eglQueryString(dpy, EGL_EXTENSIONS)).split(' ');
#endif
}
void initGL()
{
// Get OpenGL version
@ -104,9 +118,14 @@ bool hasGLXVersion(int major, int minor, int release)
return glXVersion >= MAKE_GL_VERSION(major, minor, release);
}
bool hasEGLVersion(int major, int minor, int release)
{
return eglVersion >= MAKE_GL_VERSION(major, minor, release);
}
bool hasGLExtension(const QString& extension)
{
return glExtensions.contains(extension) || glxExtensions.contains(extension);
return glExtensions.contains(extension) || glxExtensions.contains(extension) || eglExtension.contains(extension);
}
static QString formatGLError( GLenum err )

View File

@ -58,6 +58,8 @@ void KWIN_EXPORT initGLX();
// well as checking for GL version and extensions
// Note that GL context has to be created by the time this function is called
void KWIN_EXPORT initGL();
// Initializes EGL function pointers
void KWIN_EXPORT initEGL();
// Number of supported texture units
@ -66,6 +68,7 @@ extern KWIN_EXPORT int glTextureUnitsCount;
bool KWIN_EXPORT hasGLVersion(int major, int minor, int release = 0);
bool KWIN_EXPORT hasGLXVersion(int major, int minor, int release = 0);
bool KWIN_EXPORT hasEGLVersion(int major, int minor, int release = 0);
// use for both OpenGL and GLX extensions
bool KWIN_EXPORT hasGLExtension(const QString& extension);

View File

@ -38,7 +38,16 @@ SceneOpenGL::SceneOpenGL( Workspace* ws )
if( !initRenderingContext() )
return;
initEGL();
if (!hasGLExtension("EGL_KHR_image_pixmap")) {
kError(1212) << "Required extension EGL_KHR_image_pixmap not found, disabling compositing";
return;
}
initGL();
if (!hasGLExtension("GL_OES_EGL_image")) {
kError(1212) << "Required extension GL_OES_EGL_image not found, disabling compositing";
return;
}
debug = qstrcmp( qgetenv( "KWIN_GL_DEBUG" ), "1" ) == 0;
if (!setupSceneShaders()) {
kError( 1212 ) << "Shaders not valid, ES compositing not possible";