From 70fefbbbae3638ca0b96276035dba436a8f77b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 5 Dec 2010 11:55:19 +0100 Subject: [PATCH] Adding an initEGL method and check for required extension --- lib/kwinglutils.cpp | 23 +++++++++++++++++++++-- lib/kwinglutils.h | 3 +++ scene_opengl_egl.cpp | 9 +++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index 8b1311b0b5..c02efa5229 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -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 ) diff --git a/lib/kwinglutils.h b/lib/kwinglutils.h index a7b64bdd18..761a0cc5fb 100644 --- a/lib/kwinglutils.h +++ b/lib/kwinglutils.h @@ -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); diff --git a/scene_opengl_egl.cpp b/scene_opengl_egl.cpp index 5410cc7a5f..a3c26d18dd 100644 --- a/scene_opengl_egl.cpp +++ b/scene_opengl_egl.cpp @@ -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";