1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtGui module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QOPENGL_H 41 #define QOPENGL_H 42 43 #include <QtGui/qtguiglobal.h> 44 45 #ifndef QT_NO_OPENGL 46 47 // Windows always needs this to ensure that APIENTRY gets defined 48 #if defined(Q_OS_WIN) 49 # include <QtCore/qt_windows.h> 50 #endif 51 52 // Note: Apple is a "controlled platform" for OpenGL ABI so we 53 // use the system provided headers there. Controlled means that the 54 // headers always match the actual driver implementation so there 55 // is no possibility of drivers exposing additional functionality 56 // from the system headers. Also it means that the vendor can 57 // (and does) make different choices about some OpenGL types. For 58 // e.g. Apple uses void* for GLhandleARB whereas other platforms 59 // use unsigned int. 60 // 61 // For the "uncontrolled" Windows and Linux platforms we use the 62 // official Khronos headers. On these platforms this gives 63 // access to additional functionality the drivers may expose but 64 // which the system headers do not. 65 66 #if defined(QT_OPENGL_ES_2) 67 # if defined(Q_OS_IOS) || defined(Q_OS_TVOS) 68 # if defined(QT_OPENGL_ES_3) 69 # include <OpenGLES/ES3/gl.h> 70 # include <OpenGLES/ES3/glext.h> 71 # else 72 # include <OpenGLES/ES2/gl.h> 73 # include <OpenGLES/ES2/glext.h> 74 # endif 75 76 /* 77 OES_EGL_image_external is not included in the Apple provided 78 system headers yet, but we define the missing typedef so that 79 the qopenglextensions.cpp code will magically work once Apple 80 include the extension in their drivers. 81 */ 82 typedef void* GLeglImageOES; 83 84 # elif !defined(Q_OS_DARWIN) // "uncontrolled" ES2 platforms 85 86 // In "es2" builds (QT_OPENGL_ES_2) additional defines indicate GLES 3.0 or 87 // higher is available *at build time*. In this case include the corresponding 88 // header. These are backwards compatible and it should be safe to include 89 // headers on top of each other, meaning that applications can include gl2.h 90 // even if gl31.h gets included here. 91 92 // NB! The fact that Qt was built against an SDK with GLES 2 only does not mean 93 // applications cannot be deployed on a GLES 3 system. Therefore 94 // QOpenGLFunctions and friends must do everything dynamically and must not rely 95 // on these macros, except in special cases for controlled build/run environments. 96 97 // Some Khronos headers use the ext proto guard in the standard headers as well, 98 // which is bad. Work it around, but avoid spilling over to the ext header. 99 # ifndef GL_GLEXT_PROTOTYPES 100 # define GL_GLEXT_PROTOTYPES 101 # define QGL_TEMP_GLEXT_PROTO 102 # endif 103 104 # if defined(QT_OPENGL_ES_3_2) 105 # include <GLES3/gl32.h> 106 # elif defined(QT_OPENGL_ES_3_1) 107 # include <GLES3/gl31.h> 108 # elif defined(QT_OPENGL_ES_3) 109 # include <GLES3/gl3.h> 110 # else 111 # include <GLES2/gl2.h> 112 #endif 113 114 # ifdef QGL_TEMP_GLEXT_PROTO 115 # undef GL_GLEXT_PROTOTYPES 116 # undef QGL_TEMP_GLEXT_PROTO 117 # endif 118 119 /* 120 Some GLES2 implementations (like the one on Harmattan) are missing the 121 typedef for GLchar. Work around it here by adding it. The Kkronos headers 122 specify GLChar as a typedef to char, so if an implementation already 123 provides it, then this doesn't do any harm. 124 */ 125 typedef char GLchar; 126 127 # include <QtGui/qopengles2ext.h> 128 # endif // Q_OS_MAC 129 #else // non-ES2 platforms 130 # if defined(Q_OS_MAC) 131 # include <OpenGL/gl.h> 132 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED 133 # include <OpenGL/gl3.h> 134 # include <OpenGL/glext.h> 135 # else 136 # define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h 137 // Some Khronos headers use the ext proto guard in the standard headers as well, 138 // which is bad. Work it around, but avoid spilling over to the ext header. 139 # ifndef GL_GLEXT_PROTOTYPES 140 # define GL_GLEXT_PROTOTYPES 141 # include <GL/gl.h> 142 # undef GL_GLEXT_PROTOTYPES 143 # else 144 # include <GL/gl.h> 145 # endif 146 # include <QtGui/qopenglext.h> 147 # endif // Q_OS_MAC 148 #endif // QT_OPENGL_ES_2 149 150 // Desktops can support OpenGL 4. 151 #if !defined(QT_OPENGL_ES_2) 152 #define QT_OPENGL_3 153 #define QT_OPENGL_3_2 154 #define QT_OPENGL_4 155 # if !defined(Q_OS_MAC) 156 # define QT_OPENGL_4_3 157 # endif 158 #endif 159 160 QT_BEGIN_NAMESPACE 161 162 163 // When all else fails we provide sensible fallbacks - this is needed to 164 // allow compilation on OS X 10.6 165 #if !defined(QT_OPENGL_ES_2) 166 167 // OS X 10.6 doesn't define these which are needed below 168 // OS X 10.7 and later defien them in gl3.h 169 #ifndef APIENTRY 170 #define APIENTRY 171 #endif 172 #ifndef APIENTRYP 173 #define APIENTRYP APIENTRY * 174 #endif 175 #ifndef GLAPI 176 #define GLAPI extern 177 #endif 178 179 180 // This block is copied from glext.h and defines the types needed by 181 // a few extension classes. 182 183 #include <stddef.h> 184 #ifndef GL_VERSION_2_0 185 /* GL type for program/shader text */ 186 typedef char GLchar; 187 #endif 188 189 #ifndef GL_VERSION_1_5 190 /* GL types for handling large vertex buffer objects */ 191 typedef ptrdiff_t GLintptr; 192 typedef ptrdiff_t GLsizeiptr; 193 #endif 194 195 #ifndef GL_ARB_vertex_buffer_object 196 /* GL types for handling large vertex buffer objects */ 197 typedef ptrdiff_t GLintptrARB; 198 typedef ptrdiff_t GLsizeiptrARB; 199 #endif 200 201 #ifndef GL_ARB_shader_objects 202 /* GL types for program/shader text and shader object handles */ 203 typedef char GLcharARB; 204 # ifdef Q_OS_DARWIN 205 typedef void *GLhandleARB; 206 # else 207 typedef unsigned int GLhandleARB; 208 # endif // Q_OS_DARWIN 209 #endif 210 211 /* GL type for "half" precision (s10e5) float data in host memory */ 212 #ifndef GL_ARB_half_float_pixel 213 typedef unsigned short GLhalfARB; 214 #endif 215 216 #ifndef GL_NV_half_float 217 typedef unsigned short GLhalfNV; 218 #endif 219 220 #ifndef GLEXT_64_TYPES_DEFINED 221 /* This code block is duplicated in glxext.h, so must be protected */ 222 #define GLEXT_64_TYPES_DEFINED 223 /* Define int32_t, int64_t, and uint64_t types for UST/MSC */ 224 /* (as used in the GL_EXT_timer_query extension). */ 225 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 226 #include <inttypes.h> 227 #elif defined(__sun__) || defined(__digital__) 228 #include <inttypes.h> 229 #if defined(__STDC__) 230 #if defined(__arch64__) || defined(_LP64) 231 typedef long int int64_t; 232 typedef unsigned long int uint64_t; 233 #else 234 typedef long long int int64_t; 235 typedef unsigned long long int uint64_t; 236 #endif /* __arch64__ */ 237 #endif /* __STDC__ */ 238 #elif defined(__UNIXOS2__) || defined(__SOL64__) 239 typedef long int int32_t; 240 typedef long long int int64_t; 241 typedef unsigned long long int uint64_t; 242 #elif defined(_WIN32) && (defined(__GNUC__) || defined(_MSC_VER)) 243 #include <stdint.h> 244 #elif defined(_WIN32) 245 typedef __int32 int32_t; 246 typedef __int64 int64_t; 247 typedef unsigned __int64 uint64_t; 248 #else 249 /* Fallback if nothing above works */ 250 #include <inttypes.h> 251 #endif 252 #endif 253 254 #ifndef GL_EXT_timer_query 255 typedef int64_t GLint64EXT; 256 typedef uint64_t GLuint64EXT; 257 #endif 258 259 #ifndef GL_ARB_sync 260 typedef int64_t GLint64; 261 typedef uint64_t GLuint64; 262 typedef struct __GLsync *GLsync; 263 #endif 264 265 #ifndef GL_ARB_cl_event 266 /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ 267 struct _cl_context; 268 struct _cl_event; 269 #endif 270 271 #ifndef GL_ARB_debug_output 272 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); 273 #endif 274 275 #ifndef GL_AMD_debug_output 276 typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); 277 #endif 278 279 #ifndef GL_KHR_debug 280 typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); 281 #endif 282 283 #ifndef GL_NV_vdpau_interop 284 typedef GLintptr GLvdpauSurfaceNV; 285 #endif 286 287 // End of block copied from glext.h 288 #endif 289 290 291 // Types that aren't defined in all system's gl.h files. 292 typedef ptrdiff_t qopengl_GLintptr; 293 typedef ptrdiff_t qopengl_GLsizeiptr; 294 295 296 #if defined(APIENTRY) && !defined(QOPENGLF_APIENTRY) 297 # define QOPENGLF_APIENTRY APIENTRY 298 #endif 299 300 # ifndef QOPENGLF_APIENTRYP 301 # ifdef QOPENGLF_APIENTRY 302 # define QOPENGLF_APIENTRYP QOPENGLF_APIENTRY * 303 # else 304 # define QOPENGLF_APIENTRY 305 # define QOPENGLF_APIENTRYP * 306 # endif 307 # endif 308 309 QT_END_NAMESPACE 310 311 #endif // QT_NO_OPENGL 312 313 #endif // QOPENGL_H 314