Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:08:00

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QOPENGL_H
0005 #define QOPENGL_H
0006 
0007 #include <QtGui/qtguiglobal.h>
0008 
0009 #ifndef QT_NO_OPENGL
0010 
0011 // On Windows we need to ensure that APIENTRY and WINGDIAPI are defined before
0012 // we can include gl.h. But we do not want to include <windows.h> in this public
0013 // Qt header, as it pollutes the global namespace with macros.
0014 #if defined(Q_OS_WIN)
0015 # ifndef APIENTRY
0016 #  define APIENTRY __stdcall
0017 #  define Q_UNDEF_APIENTRY
0018 # endif // APIENTRY
0019 # ifndef WINGDIAPI
0020 #  define WINGDIAPI __declspec(dllimport)
0021 #  define Q_UNDEF_WINGDIAPI
0022 # endif // WINGDIAPI
0023 # define QT_APIENTRY __stdcall
0024 #endif
0025 
0026 // Note: Apple is a "controlled platform" for OpenGL ABI so we
0027 // use the system provided headers there. Controlled means that the
0028 // headers always match the actual driver implementation so there
0029 // is no possibility of drivers exposing additional functionality
0030 // from the system headers. Also it means that the vendor can
0031 // (and does) make different choices about some OpenGL types. For
0032 // e.g. Apple uses void* for GLhandleARB whereas other platforms
0033 // use unsigned int.
0034 //
0035 // For the "uncontrolled" Windows and Linux platforms we use the
0036 // official Khronos headers. On these platforms this gives
0037 // access to additional functionality the drivers may expose but
0038 // which the system headers do not.
0039 
0040 #if QT_CONFIG(opengles2)
0041 # if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
0042 #  if QT_CONFIG(opengles3)
0043 #   include <OpenGLES/ES3/gl.h>
0044 #   include <OpenGLES/ES3/glext.h>
0045 #  else
0046 #   include <OpenGLES/ES2/gl.h>
0047 #   include <OpenGLES/ES2/glext.h>
0048 #  endif
0049 
0050 /*
0051    OES_EGL_image_external is not included in the Apple provided
0052    system headers yet, but we define the missing typedef so that
0053    the qopenglextensions.cpp code will magically work once Apple
0054    include the extension in their drivers.
0055 */
0056 typedef void* GLeglImageOES;
0057 
0058 # elif !defined(Q_OS_DARWIN) // "uncontrolled" ES2 platforms
0059 
0060 // In "es2" builds (QT_CONFIG(opengles2)) additional defines indicate GLES 3.0 or
0061 // higher is available *at build time*. In this case include the corresponding
0062 // header. These are backwards compatible and it should be safe to include
0063 // headers on top of each other, meaning that applications can include gl2.h
0064 // even if gl31.h gets included here.
0065 
0066 // NB! The fact that Qt was built against an SDK with GLES 2 only does not mean
0067 // applications cannot be deployed on a GLES 3 system. Therefore
0068 // QOpenGLFunctions and friends must do everything dynamically and must not rely
0069 // on these macros, except in special cases for controlled build/run environments.
0070 
0071 // Some Khronos headers use the ext proto guard in the standard headers as well,
0072 // which is bad. Work it around, but avoid spilling over to the ext header.
0073 #  ifndef GL_GLEXT_PROTOTYPES
0074 #   define GL_GLEXT_PROTOTYPES
0075 #   define QGL_TEMP_GLEXT_PROTO
0076 #  endif
0077 
0078 #  if QT_CONFIG(opengles32)
0079 #   include <GLES3/gl32.h>
0080 #  elif QT_CONFIG(opengles31)
0081 #   include <GLES3/gl31.h>
0082 #  elif QT_CONFIG(opengles3)
0083 #   include <GLES3/gl3.h>
0084 #  else
0085 #   include <GLES2/gl2.h>
0086 #  endif
0087 
0088 #  ifdef QGL_TEMP_GLEXT_PROTO
0089 #   undef GL_GLEXT_PROTOTYPES
0090 #   undef QGL_TEMP_GLEXT_PROTO
0091 #  endif
0092 
0093 /*
0094    Some GLES2 implementations (like the one on Harmattan) are missing the
0095    typedef for GLchar. Work around it here by adding it. The Kkronos headers
0096    specify GLChar as a typedef to char, so if an implementation already
0097    provides it, then this doesn't do any harm.
0098 */
0099 typedef char GLchar;
0100 
0101 #  include <QtGui/qopengles2ext.h>
0102 # endif
0103 #else // non-ES2 platforms
0104 # if defined(Q_OS_MACOS)
0105 #  include <OpenGL/gl.h>
0106 #  define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
0107 #  include <OpenGL/gl3.h>
0108 #  include <OpenGL/glext.h>
0109 # else
0110 #  define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h
0111 // Some Khronos headers use the ext proto guard in the standard headers as well,
0112 // which is bad. Work it around, but avoid spilling over to the ext header.
0113 #  ifndef GL_GLEXT_PROTOTYPES
0114 #   define GL_GLEXT_PROTOTYPES
0115 #   include <GL/gl.h>
0116 #   undef GL_GLEXT_PROTOTYPES
0117 #  else
0118 #   include <GL/gl.h>
0119 #  endif
0120 #  include <QtGui/qopenglext.h>
0121 # endif
0122 #endif // !QT_CONFIG(opengles2)
0123 
0124 // Desktops can support OpenGL 4.
0125 #if !QT_CONFIG(opengles2)
0126 #define QT_OPENGL_3
0127 #define QT_OPENGL_3_2
0128 #define QT_OPENGL_4
0129 # if !defined(Q_OS_MAC)
0130 #  define QT_OPENGL_4_3
0131 # endif
0132 #endif
0133 
0134 
0135 // When all else fails we provide sensible fallbacks - this is needed to
0136 // allow compilation on OS X 10.6
0137 #if !QT_CONFIG(opengles2)
0138 
0139 // OS X 10.6 doesn't define these which are needed below
0140 // OS X 10.7 and later define them in gl3.h
0141 #ifndef QT_APIENTRY
0142 #define QT_APIENTRY
0143 #endif
0144 #ifndef QT_APIENTRYP
0145 #define QT_APIENTRYP QT_APIENTRY *
0146 #endif
0147 #ifndef GLAPI
0148 #define GLAPI extern
0149 #endif
0150 
0151 
0152 // This block is copied from glext.h and defines the types needed by
0153 // a few extension classes.
0154 
0155 #include <stddef.h>
0156 #ifndef GL_VERSION_2_0
0157 /* GL type for program/shader text */
0158 typedef char GLchar;
0159 #endif
0160 
0161 #ifndef GL_VERSION_1_5
0162 /* GL types for handling large vertex buffer objects */
0163 typedef ptrdiff_t GLintptr;
0164 typedef ptrdiff_t GLsizeiptr;
0165 #endif
0166 
0167 #ifndef GL_ARB_vertex_buffer_object
0168 /* GL types for handling large vertex buffer objects */
0169 typedef ptrdiff_t GLintptrARB;
0170 typedef ptrdiff_t GLsizeiptrARB;
0171 #endif
0172 
0173 #ifndef GL_ARB_shader_objects
0174 /* GL types for program/shader text and shader object handles */
0175 typedef char GLcharARB;
0176 # ifdef Q_OS_DARWIN
0177 typedef void *GLhandleARB;
0178 # else
0179 typedef unsigned int GLhandleARB;
0180 # endif // Q_OS_DARWIN
0181 #endif
0182 
0183 /* GL type for "half" precision (s10e5) float data in host memory */
0184 #ifndef GL_ARB_half_float_pixel
0185 typedef unsigned short GLhalfARB;
0186 #endif
0187 
0188 #ifndef GL_NV_half_float
0189 typedef unsigned short GLhalfNV;
0190 #endif
0191 
0192 #ifndef GLEXT_64_TYPES_DEFINED
0193 /* This code block is duplicated in glxext.h, so must be protected */
0194 #define GLEXT_64_TYPES_DEFINED
0195 /* Define int32_t, int64_t, and uint64_t types for UST/MSC */
0196 /* (as used in the GL_EXT_timer_query extension). */
0197 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
0198 #include <inttypes.h>
0199 #elif defined(__sun__) || defined(__digital__)
0200 #include <inttypes.h>
0201 #if defined(__STDC__)
0202 #if defined(__arch64__) || defined(_LP64)
0203 typedef long int int64_t;
0204 typedef unsigned long int uint64_t;
0205 #else
0206 typedef long long int int64_t;
0207 typedef unsigned long long int uint64_t;
0208 #endif /* __arch64__ */
0209 #endif /* __STDC__ */
0210 #elif defined(__UNIXOS2__) || defined(__SOL64__)
0211 typedef long int int32_t;
0212 typedef long long int int64_t;
0213 typedef unsigned long long int uint64_t;
0214 #elif defined(_WIN32) && (defined(__GNUC__) || defined(_MSC_VER))
0215 #include <stdint.h>
0216 #elif defined(_WIN32)
0217 typedef __int32 int32_t;
0218 typedef __int64 int64_t;
0219 typedef unsigned __int64 uint64_t;
0220 #else
0221 /* Fallback if nothing above works */
0222 #include <inttypes.h>
0223 #endif
0224 #endif
0225 
0226 #ifndef GL_EXT_timer_query
0227 typedef int64_t GLint64EXT;
0228 typedef uint64_t GLuint64EXT;
0229 #endif
0230 
0231 #ifndef GL_ARB_sync
0232 typedef int64_t GLint64;
0233 typedef uint64_t GLuint64;
0234 typedef struct __GLsync *GLsync;
0235 #endif
0236 
0237 #ifndef GL_ARB_cl_event
0238 /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */
0239 struct _cl_context;
0240 struct _cl_event;
0241 #endif
0242 
0243 #ifndef GL_ARB_debug_output
0244 typedef void (QT_APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam);
0245 #endif
0246 
0247 #ifndef GL_AMD_debug_output
0248 typedef void (QT_APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
0249 #endif
0250 
0251 #ifndef GL_KHR_debug
0252 typedef void (QT_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam);
0253 #endif
0254 
0255 #ifndef GL_NV_vdpau_interop
0256 typedef GLintptr GLvdpauSurfaceNV;
0257 #endif
0258 
0259 // End of block copied from glext.h
0260 #endif
0261 
0262 QT_BEGIN_NAMESPACE
0263 
0264 // Types that aren't defined in all system's gl.h files.
0265 typedef ptrdiff_t qopengl_GLintptr;
0266 typedef ptrdiff_t qopengl_GLsizeiptr;
0267 
0268 
0269 #if defined(QT_APIENTRY) && !defined(QOPENGLF_APIENTRY)
0270 #   define QOPENGLF_APIENTRY QT_APIENTRY
0271 #endif
0272 
0273 # ifndef QOPENGLF_APIENTRYP
0274 #   ifdef QOPENGLF_APIENTRY
0275 #     define QOPENGLF_APIENTRYP QOPENGLF_APIENTRY *
0276 #   else
0277 #     define QOPENGLF_APIENTRY
0278 #     define QOPENGLF_APIENTRYP *
0279 #   endif
0280 # endif
0281 
0282 QT_END_NAMESPACE
0283 
0284 #ifdef Q_UNDEF_WINGDIAPI
0285 # undef WINGDIAPI
0286 # undef Q_UNDEF_WINGDIAPI
0287 #endif
0288 #ifdef Q_UNDEF_APIENTRY
0289 # undef APIENTRY
0290 # undef Q_UNDEF_APIENTRY
0291 #endif
0292 
0293 #endif // QT_NO_OPENGL
0294 
0295 #endif // QOPENGL_H