From f05d5888c9c37302e0a0eebf7e7eca65017ebf5f Mon Sep 17 00:00:00 2001 From: StefanBruens Date: Sun, 2 Feb 2020 14:29:04 +0100 Subject: [PATCH] Merge pull request #16479 from StefanBruens:fix_gles_glx_h_include Fix compilation errors on GLES platforms * Do not include glx.h when using GLES GL/glx.h is included on all LINUX plattforms, which is wrong for a number of reasons: - GL_PERSPECTIVE_CORRECTION_HINT is defined in GL/gl.h, so we want gl.h not glx.h, the latter just includes the former - GL/gl.h is a Desktop GL header, and should not be included on GLES plattforms - GL/gl.h is already included via QtOpenGL -> QtGui/qopengl.h on desktop plattforms This fixes a problem when Qt is compiled with GLES, which is often done on ARM platforms where desktop GL is not or only poorly supported (e.g. slow due to emulation). Fixes part of #9171. * Only set GL_PERSPECTIVE_CORRECTION_HINT when GL version defines it GL_PERSPECTIVE_CORRECTION_HINT does not exist in GLES 2.0/3.x, and has been deprecated in OpenGL 3.0 core profiles. Fixes part of #9171. --- modules/highgui/src/window_QT.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 1acd0d1672..e83a442c6a 100644 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -54,9 +54,12 @@ #include #endif +// Get GL_PERSPECTIVE_CORRECTION_HINT definition, not available in GLES 2 or +// OpenGL 3 core profile or later #ifdef HAVE_QT_OPENGL - #if defined Q_WS_X11 /* Qt4 */ || defined Q_OS_LINUX /* Qt5 */ - #include + #if defined Q_WS_X11 /* Qt4 */ || \ + (!defined(QT_OPENGL_ES_2) && defined Q_OS_LINUX) /* Qt5 with desktop OpenGL */ + #include #endif #endif @@ -3226,7 +3229,9 @@ void OpenGlViewPort::updateGl() void OpenGlViewPort::initializeGL() { +#ifdef GL_PERSPECTIVE_CORRECTION_HINT glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); +#endif } void OpenGlViewPort::resizeGL(int w, int h)