Enable GL prototypes with recent Khronos headers

Recent Khronos headers decided to break the world by guarding all
function prototypes with GL_GLEXT_PROTOTYPES which has traditionally
been used for extension headers only.

Until this gets corrected - see
https://lists.freedesktop.org/archives/mesa-dev/2016-September/128654.html
- add the define to the config tests and qopengl.h.

While 5.7 already has some of the qopengl.h fixes due to an upgraded
ANGLE shipping with newer headers, this is a cross-platform issue that
will surface everywhere eventually. Therefore we target the full set
of fixes to 5.6.

This time we also make sure the forced define of GL_GLEXT_PROTOTYPES
is removed before including the ext header, thus apps get the ext
protos only if they actually requested them.

Task-number: QTBUG-56764
Change-Id: Ib2c6d2e7b71b8fb8683424f43e6289e64e4ee46c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2016-10-27 11:38:57 +02:00
parent 5fcda45872
commit e8364f9a4b
4 changed files with 24 additions and 1 deletions

View File

@ -34,6 +34,7 @@
#ifdef __APPLE__ #ifdef __APPLE__
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#else #else
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h> #include <GL/gl.h>
#endif #endif

View File

@ -34,6 +34,7 @@
#ifdef BUILD_ON_MAC #ifdef BUILD_ON_MAC
#include <OpenGLES/ES2/gl.h> #include <OpenGLES/ES2/gl.h>
#else #else
#define GL_GLEXT_PROTOTYPES
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#endif #endif

View File

@ -34,6 +34,7 @@
#ifdef BUILD_ON_MAC #ifdef BUILD_ON_MAC
#include <OpenGLES/ES3/gl.h> #include <OpenGLES/ES3/gl.h>
#else #else
#define GL_GLEXT_PROTOTYPES
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#endif #endif

View File

@ -89,6 +89,13 @@ typedef void* GLeglImageOES;
// applications cannot target ES 3. Therefore QOpenGLFunctions and // applications cannot target ES 3. Therefore QOpenGLFunctions and
// friends do everything dynamically and never rely on these macros. // friends do everything dynamically and never rely on these macros.
// Some Khronos headers use the ext proto guard in the standard headers as well,
// which is bad. Work it around, but avoid spilling over to the ext header.
# ifndef GL_GLEXT_PROTOTYPES
# define GL_GLEXT_PROTOTYPES
# define QGL_TEMP_GLEXT_PROTO
# endif
# if defined(QT_OPENGL_ES_3_1) # if defined(QT_OPENGL_ES_3_1)
# include <GLES3/gl31.h> # include <GLES3/gl31.h>
# elif defined(QT_OPENGL_ES_3) # elif defined(QT_OPENGL_ES_3)
@ -97,6 +104,11 @@ typedef void* GLeglImageOES;
# include <GLES2/gl2.h> # include <GLES2/gl2.h>
#endif #endif
# ifdef QGL_TEMP_GLEXT_PROTO
# undef GL_GLEXT_PROTOTYPES
# undef QGL_TEMP_GLEXT_PROTO
# endif
/* /*
Some GLES2 implementations (like the one on Harmattan) are missing the Some GLES2 implementations (like the one on Harmattan) are missing the
typedef for GLchar. Work around it here by adding it. The Kkronos headers typedef for GLchar. Work around it here by adding it. The Kkronos headers
@ -117,7 +129,15 @@ typedef char GLchar;
# include <OpenGL/glext.h> # include <OpenGL/glext.h>
# else # else
# define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h # define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h
// Some Khronos headers use the ext proto guard in the standard headers as well,
// which is bad. Work it around, but avoid spilling over to the ext header.
# ifndef GL_GLEXT_PROTOTYPES
# define GL_GLEXT_PROTOTYPES
# include <GL/gl.h> # include <GL/gl.h>
# undef GL_GLEXT_PROTOTYPES
# else
# include <GL/gl.h>
# endif
# include <QtGui/qopenglext.h> # include <QtGui/qopenglext.h>
# endif // Q_OS_MAC # endif // Q_OS_MAC
#endif // QT_OPENGL_ES_2 #endif // QT_OPENGL_ES_2