qopengl.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. #ifndef QOPENGL_H
  40. #define QOPENGL_H
  41. #include <QtCore/qglobal.h>
  42. #ifndef QT_NO_OPENGL
  43. // Windows always needs this to ensure that APIENTRY gets defined
  44. #if defined(Q_OS_WIN)
  45. # include <QtCore/qt_windows.h>
  46. #endif
  47. // Note: Mac OSX is a "controlled platform" for OpenGL ABI so we
  48. // use the system provided headers there. Controlled means that the
  49. // headers always match the actual driver implementation so there
  50. // is no possibility of drivers exposing additional functionality
  51. // from the system headers. Also it means that the vendor can
  52. // (and does) make different choices about some OpenGL types. For
  53. // e.g. Apple uses void* for GLhandleARB whereas other platforms
  54. // use unsigned int.
  55. //
  56. // For the "uncontrolled" Windows and Linux platforms we use the
  57. // official Khronos headers. On these platforms this gives
  58. // access to additional functionality the drivers may expose but
  59. // which the system headers do not.
  60. #if defined(QT_OPENGL_ES_2)
  61. # if defined(Q_OS_MAC) // iOS
  62. # if defined(QT_OPENGL_ES_3)
  63. # include <OpenGLES/ES3/gl.h>
  64. # include <OpenGLES/ES3/glext.h>
  65. # else
  66. # include <OpenGLES/ES2/gl.h>
  67. # include <OpenGLES/ES2/glext.h>
  68. # endif
  69. /*
  70. OES_EGL_image_external is not included in the Apple provided
  71. system headers yet, but we define the missing typedef so that
  72. the qopenglextensions.cpp code will magically work once Apple
  73. include the extension in their drivers.
  74. */
  75. typedef void* GLeglImageOES;
  76. # else // "uncontrolled" ES2 platforms
  77. // In "es2" builds (QT_OPENGL_ES_2) additional defines indicate if ES
  78. // 3.0 or higher is available. In this case include the corresponding
  79. // header. These are backwards compatible and it should be safe to
  80. // include headers on top of each other, meaning that applications can
  81. // include gl2.h even if gl31.h gets included here.
  82. // NB! This file contains the only usages of the ES_3 and ES_3_1
  83. // macros. They are useless for pretty much anything else. The fact
  84. // that Qt was built against an SDK with f.ex. ES 2 only does not mean
  85. // applications cannot target ES 3. Therefore QOpenGLFunctions and
  86. // friends do everything dynamically and never rely on these macros.
  87. # if defined(QT_OPENGL_ES_3_1)
  88. # include <GLES3/gl31.h>
  89. # elif defined(QT_OPENGL_ES_3)
  90. # include <GLES3/gl3.h>
  91. # else
  92. # ifndef GL_GLEXT_PROTOTYPES
  93. # define GL_GLEXT_PROTOTYPES
  94. # endif
  95. # include <GLES2/gl2.h>
  96. #endif
  97. /*
  98. Some GLES2 implementations (like the one on Harmattan) are missing the
  99. typedef for GLchar. Work around it here by adding it. The Kkronos headers
  100. specify GLChar as a typedef to char, so if an implementation already
  101. provides it, then this doesn't do any harm.
  102. */
  103. typedef char GLchar;
  104. # include <QtGui/qopengles2ext.h>
  105. # endif // Q_OS_MAC
  106. #else // non-ES2 platforms
  107. # if defined(Q_OS_MAC)
  108. # include <OpenGL/gl.h>
  109. # if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
  110. # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
  111. # include <OpenGL/gl3.h>
  112. # endif
  113. # include <OpenGL/glext.h>
  114. # else
  115. # define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h
  116. # include <GL/gl.h>
  117. # include <QtGui/qopenglext.h>
  118. # endif // Q_OS_MAC
  119. #endif // QT_OPENGL_ES_2
  120. // Desktops, apart from Mac OS X prior to 10.7 can support OpenGL 3.
  121. // Desktops, apart from Mac OS X prior to 10.9 can support OpenGL 4.
  122. #if !defined(QT_OPENGL_ES_2)
  123. # if !defined(Q_OS_MAC) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
  124. # define QT_OPENGL_3
  125. # define QT_OPENGL_3_2
  126. # endif
  127. # if !defined(Q_OS_MAC) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9)
  128. # define QT_OPENGL_4
  129. # endif
  130. # if !defined(Q_OS_MAC)
  131. # define QT_OPENGL_4_3
  132. # endif
  133. #endif
  134. QT_BEGIN_NAMESPACE
  135. // When all else fails we provide sensible fallbacks - this is needed to
  136. // allow compilation on OS X 10.6
  137. #if !defined(QT_OPENGL_ES_2)
  138. // OS X 10.6 doesn't define these which are needed below
  139. // OS X 10.7 and later defien them in gl3.h
  140. #ifndef APIENTRY
  141. #define APIENTRY
  142. #endif
  143. #ifndef APIENTRYP
  144. #define APIENTRYP APIENTRY *
  145. #endif
  146. #ifndef GLAPI
  147. #define GLAPI extern
  148. #endif
  149. // This block is copied from glext.h and defines the types needed by
  150. // a few extension classes.
  151. #include <stddef.h>
  152. #ifndef GL_VERSION_2_0
  153. /* GL type for program/shader text */
  154. typedef char GLchar;
  155. #endif
  156. #ifndef GL_VERSION_1_5
  157. /* GL types for handling large vertex buffer objects */
  158. typedef ptrdiff_t GLintptr;
  159. typedef ptrdiff_t GLsizeiptr;
  160. #endif
  161. #ifndef GL_ARB_vertex_buffer_object
  162. /* GL types for handling large vertex buffer objects */
  163. typedef ptrdiff_t GLintptrARB;
  164. typedef ptrdiff_t GLsizeiptrARB;
  165. #endif
  166. #ifndef GL_ARB_shader_objects
  167. /* GL types for program/shader text and shader object handles */
  168. typedef char GLcharARB;
  169. # ifdef Q_OS_DARWIN
  170. typedef void *GLhandleARB;
  171. # else
  172. typedef unsigned int GLhandleARB;
  173. # endif // Q_OS_DARWIN
  174. #endif
  175. /* GL type for "half" precision (s10e5) float data in host memory */
  176. #ifndef GL_ARB_half_float_pixel
  177. typedef unsigned short GLhalfARB;
  178. #endif
  179. #ifndef GL_NV_half_float
  180. typedef unsigned short GLhalfNV;
  181. #endif
  182. #ifndef GLEXT_64_TYPES_DEFINED
  183. /* This code block is duplicated in glxext.h, so must be protected */
  184. #define GLEXT_64_TYPES_DEFINED
  185. /* Define int32_t, int64_t, and uint64_t types for UST/MSC */
  186. /* (as used in the GL_EXT_timer_query extension). */
  187. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  188. #include <inttypes.h>
  189. #elif defined(__sun__) || defined(__digital__)
  190. #include <inttypes.h>
  191. #if defined(__STDC__)
  192. #if defined(__arch64__) || defined(_LP64)
  193. typedef long int int64_t;
  194. typedef unsigned long int uint64_t;
  195. #else
  196. typedef long long int int64_t;
  197. typedef unsigned long long int uint64_t;
  198. #endif /* __arch64__ */
  199. #endif /* __STDC__ */
  200. #elif defined( __VMS ) || defined(__sgi)
  201. #include <inttypes.h>
  202. #elif defined(__SCO__) || defined(__USLC__)
  203. #include <stdint.h>
  204. #elif defined(__UNIXOS2__) || defined(__SOL64__)
  205. typedef long int int32_t;
  206. typedef long long int int64_t;
  207. typedef unsigned long long int uint64_t;
  208. #elif defined(_WIN32) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1600))
  209. #include <stdint.h>
  210. #elif defined(_WIN32)
  211. typedef __int32 int32_t;
  212. typedef __int64 int64_t;
  213. typedef unsigned __int64 uint64_t;
  214. #else
  215. /* Fallback if nothing above works */
  216. #include <inttypes.h>
  217. #endif
  218. #endif
  219. #ifndef GL_EXT_timer_query
  220. typedef int64_t GLint64EXT;
  221. typedef uint64_t GLuint64EXT;
  222. #endif
  223. #ifndef GL_ARB_sync
  224. typedef int64_t GLint64;
  225. typedef uint64_t GLuint64;
  226. typedef struct __GLsync *GLsync;
  227. #endif
  228. #ifndef GL_ARB_cl_event
  229. /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */
  230. struct _cl_context;
  231. struct _cl_event;
  232. #endif
  233. #ifndef GL_ARB_debug_output
  234. typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam);
  235. #endif
  236. #ifndef GL_AMD_debug_output
  237. typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
  238. #endif
  239. #ifndef GL_KHR_debug
  240. typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam);
  241. #endif
  242. #ifndef GL_NV_vdpau_interop
  243. typedef GLintptr GLvdpauSurfaceNV;
  244. #endif
  245. // End of block copied from glext.h
  246. #endif
  247. // Types that aren't defined in all system's gl.h files.
  248. typedef ptrdiff_t qopengl_GLintptr;
  249. typedef ptrdiff_t qopengl_GLsizeiptr;
  250. #if defined(APIENTRY) && !defined(QOPENGLF_APIENTRY)
  251. # define QOPENGLF_APIENTRY APIENTRY
  252. #endif
  253. # ifndef QOPENGLF_APIENTRYP
  254. # ifdef QOPENGLF_APIENTRY
  255. # define QOPENGLF_APIENTRYP QOPENGLF_APIENTRY *
  256. # else
  257. # define QOPENGLF_APIENTRY
  258. # define QOPENGLF_APIENTRYP *
  259. # endif
  260. # endif
  261. QT_END_NAMESPACE
  262. #endif // QT_NO_OPENGL
  263. #endif // QOPENGL_H