Adding an initEGL method and check for required extension
This commit is contained in:
parent
d12c4e58fd
commit
70fefbbbae
3 changed files with 33 additions and 2 deletions
|
@ -48,9 +48,12 @@ namespace KWin
|
||||||
static int glVersion;
|
static int glVersion;
|
||||||
// GLX version, use MAKE_GL_VERSION() macro for comparing with a specific version
|
// GLX version, use MAKE_GL_VERSION() macro for comparing with a specific version
|
||||||
static int glXVersion;
|
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 glExtensions;
|
||||||
static QStringList glxExtensions;
|
static QStringList glxExtensions;
|
||||||
|
static QStringList eglExtension;
|
||||||
|
|
||||||
int glTextureUnitsCount;
|
int glTextureUnitsCount;
|
||||||
|
|
||||||
|
@ -71,6 +74,17 @@ void initGLX()
|
||||||
#endif
|
#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()
|
void initGL()
|
||||||
{
|
{
|
||||||
// Get OpenGL version
|
// Get OpenGL version
|
||||||
|
@ -104,9 +118,14 @@ bool hasGLXVersion(int major, int minor, int release)
|
||||||
return glXVersion >= MAKE_GL_VERSION(major, minor, 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)
|
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 )
|
static QString formatGLError( GLenum err )
|
||||||
|
|
|
@ -58,6 +58,8 @@ void KWIN_EXPORT initGLX();
|
||||||
// well as checking for GL version and extensions
|
// well as checking for GL version and extensions
|
||||||
// Note that GL context has to be created by the time this function is called
|
// Note that GL context has to be created by the time this function is called
|
||||||
void KWIN_EXPORT initGL();
|
void KWIN_EXPORT initGL();
|
||||||
|
// Initializes EGL function pointers
|
||||||
|
void KWIN_EXPORT initEGL();
|
||||||
|
|
||||||
|
|
||||||
// Number of supported texture units
|
// 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 hasGLVersion(int major, int minor, int release = 0);
|
||||||
bool KWIN_EXPORT hasGLXVersion(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
|
// use for both OpenGL and GLX extensions
|
||||||
bool KWIN_EXPORT hasGLExtension(const QString& extension);
|
bool KWIN_EXPORT hasGLExtension(const QString& extension);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,16 @@ SceneOpenGL::SceneOpenGL( Workspace* ws )
|
||||||
if( !initRenderingContext() )
|
if( !initRenderingContext() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
initEGL();
|
||||||
|
if (!hasGLExtension("EGL_KHR_image_pixmap")) {
|
||||||
|
kError(1212) << "Required extension EGL_KHR_image_pixmap not found, disabling compositing";
|
||||||
|
return;
|
||||||
|
}
|
||||||
initGL();
|
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;
|
debug = qstrcmp( qgetenv( "KWIN_GL_DEBUG" ), "1" ) == 0;
|
||||||
if (!setupSceneShaders()) {
|
if (!setupSceneShaders()) {
|
||||||
kError( 1212 ) << "Shaders not valid, ES compositing not possible";
|
kError( 1212 ) << "Shaders not valid, ES compositing not possible";
|
||||||
|
|
Loading…
Reference in a new issue