QtBase  v6.3.1
qopengl.h
Go to the documentation of this file.
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 QT_CONFIG(opengles2)
67 # if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
68 # if QT_CONFIG(opengles3)
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_CONFIG(opengles2)) 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 QT_CONFIG(opengles32)
105 # include <GLES3/gl32.h>
106 # elif QT_CONFIG(opengles31)
107 # include <GLES3/gl31.h>
108 # elif QT_CONFIG(opengles3)
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
129 #else // non-ES2 platforms
130 # if defined(Q_OS_MACOS)
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
148 #endif // !QT_CONFIG(opengles2)
149 
150 // Desktops can support OpenGL 4.
151 #if !QT_CONFIG(opengles2)
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 
161 // When all else fails we provide sensible fallbacks - this is needed to
162 // allow compilation on OS X 10.6
163 #if !QT_CONFIG(opengles2)
164 
165 // OS X 10.6 doesn't define these which are needed below
166 // OS X 10.7 and later define them in gl3.h
167 #ifndef APIENTRY
168 #define APIENTRY
169 #endif
170 #ifndef APIENTRYP
171 #define APIENTRYP APIENTRY *
172 #endif
173 #ifndef GLAPI
174 #define GLAPI extern
175 #endif
176 
177 
178 // This block is copied from glext.h and defines the types needed by
179 // a few extension classes.
180 
181 #include <stddef.h>
182 #ifndef GL_VERSION_2_0
183 /* GL type for program/shader text */
184 typedef char GLchar;
185 #endif
186 
187 #ifndef GL_VERSION_1_5
188 /* GL types for handling large vertex buffer objects */
189 typedef ptrdiff_t GLintptr;
190 typedef ptrdiff_t GLsizeiptr;
191 #endif
192 
193 #ifndef GL_ARB_vertex_buffer_object
194 /* GL types for handling large vertex buffer objects */
195 typedef ptrdiff_t GLintptrARB;
196 typedef ptrdiff_t GLsizeiptrARB;
197 #endif
198 
199 #ifndef GL_ARB_shader_objects
200 /* GL types for program/shader text and shader object handles */
201 typedef char GLcharARB;
202 # ifdef Q_OS_DARWIN
203 typedef void *GLhandleARB;
204 # else
205 typedef unsigned int GLhandleARB;
206 # endif // Q_OS_DARWIN
207 #endif
208 
209 /* GL type for "half" precision (s10e5) float data in host memory */
210 #ifndef GL_ARB_half_float_pixel
211 typedef unsigned short GLhalfARB;
212 #endif
213 
214 #ifndef GL_NV_half_float
215 typedef unsigned short GLhalfNV;
216 #endif
217 
218 #ifndef GLEXT_64_TYPES_DEFINED
219 /* This code block is duplicated in glxext.h, so must be protected */
220 #define GLEXT_64_TYPES_DEFINED
221 /* Define int32_t, int64_t, and uint64_t types for UST/MSC */
222 /* (as used in the GL_EXT_timer_query extension). */
223 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
224 #include <inttypes.h>
225 #elif defined(__sun__) || defined(__digital__)
226 #include <inttypes.h>
227 #if defined(__STDC__)
228 #if defined(__arch64__) || defined(_LP64)
229 typedef long int int64_t;
230 typedef unsigned long int uint64_t;
231 #else
232 typedef long long int int64_t;
233 typedef unsigned long long int uint64_t;
234 #endif /* __arch64__ */
235 #endif /* __STDC__ */
236 #elif defined(__UNIXOS2__) || defined(__SOL64__)
237 typedef long int int32_t;
238 typedef long long int int64_t;
239 typedef unsigned long long int uint64_t;
240 #elif defined(_WIN32) && (defined(__GNUC__) || defined(_MSC_VER))
241 #include <stdint.h>
242 #elif defined(_WIN32)
243 typedef __int32 int32_t;
244 typedef __int64 int64_t;
245 typedef unsigned __int64 uint64_t;
246 #else
247 /* Fallback if nothing above works */
248 #include <inttypes.h>
249 #endif
250 #endif
251 
252 #ifndef GL_EXT_timer_query
253 typedef int64_t GLint64EXT;
254 typedef uint64_t GLuint64EXT;
255 #endif
256 
257 #ifndef GL_ARB_sync
258 typedef int64_t GLint64;
259 typedef uint64_t GLuint64;
260 typedef struct __GLsync *GLsync;
261 #endif
262 
263 #ifndef GL_ARB_cl_event
264 /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */
265 struct _cl_context;
266 struct _cl_event;
267 #endif
268 
269 #ifndef GL_ARB_debug_output
271 #endif
272 
273 #ifndef GL_AMD_debug_output
275 #endif
276 
277 #ifndef GL_KHR_debug
279 #endif
280 
281 #ifndef GL_NV_vdpau_interop
283 #endif
284 
285 // End of block copied from glext.h
286 #endif
287 
289 
290 // Types that aren't defined in all system's gl.h files.
291 typedef ptrdiff_t qopengl_GLintptr;
292 typedef ptrdiff_t qopengl_GLsizeiptr;
293 
294 
295 #if defined(APIENTRY) && !defined(QOPENGLF_APIENTRY)
296 # define QOPENGLF_APIENTRY APIENTRY
297 #endif
298 
299 # ifndef QOPENGLF_APIENTRYP
300 # ifdef QOPENGLF_APIENTRY
301 # define QOPENGLF_APIENTRYP QOPENGLF_APIENTRY *
302 # else
303 # define QOPENGLF_APIENTRY
304 # define QOPENGLF_APIENTRYP *
305 # endif
306 # endif
307 
309 
310 #endif // QT_NO_OPENGL
311 
312 #endif // QOPENGL_H
const QLoggingCategory & category()
[1]
ptrdiff_t GLintptr
Definition: qopengl.h:189
int64_t GLint64EXT
Definition: qopengl.h:253
uint64_t GLuint64
Definition: qopengl.h:259
uint64_t GLuint64EXT
Definition: qopengl.h:254
ptrdiff_t GLsizeiptrARB
Definition: qopengl.h:196
unsigned short GLhalfNV
Definition: qopengl.h:215
#define APIENTRY
Definition: qopengl.h:168
ptrdiff_t GLintptrARB
Definition: qopengl.h:195
GLenum GLuint GLenum GLsizei length
Definition: qopengl.h:270
GLenum GLuint id
[6]
Definition: qopengl.h:270
GLintptr GLvdpauSurfaceNV
Definition: qopengl.h:282
GLenum GLuint GLenum GLsizei const GLchar const GLvoid * userParam
Definition: qopengl.h:270
void(APIENTRY * GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam)
Definition: qopengl.h:278
int64_t GLint64
Definition: qopengl.h:258
GLenum type
Definition: qopengl.h:270
unsigned int GLhandleARB
Definition: qopengl.h:205
QT_BEGIN_NAMESPACE typedef ptrdiff_t qopengl_GLintptr
Definition: qopengl.h:291
ptrdiff_t qopengl_GLsizeiptr
Definition: qopengl.h:292
void(APIENTRY * GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam)
Definition: qopengl.h:274
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
ptrdiff_t GLsizeiptr
Definition: qopengl.h:190
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: qopengl.h:270
char GLcharARB
Definition: qopengl.h:201
GLenum GLuint GLenum severity
Definition: qopengl.h:270
unsigned short GLhalfARB
Definition: qopengl.h:211
struct __GLsync * GLsync
Definition: qopengl.h:260
char GLchar
Definition: qopengl.h:184
typedef GLsizei(GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target)
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
void * GLeglImageOES
GLsizei GLsizei GLchar * source
void(APIENTRY * GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
Definition: qopenglext.h:3075