qopenglfunctions.h 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179
  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 QOPENGLFUNCTIONS_H
  40. #define QOPENGLFUNCTIONS_H
  41. #include <QtCore/qglobal.h>
  42. #ifndef QT_NO_OPENGL
  43. #ifdef __GLEW_H__
  44. #if defined(Q_CC_GNU)
  45. #warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
  46. #warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
  47. #endif
  48. #endif
  49. #include <QtGui/qopengl.h>
  50. #include <QtGui/qopenglcontext.h>
  51. //#define Q_ENABLE_OPENGL_FUNCTIONS_DEBUG
  52. #ifdef QT_OPENGL_ES
  53. typedef double GLdouble;
  54. #endif
  55. #ifdef Q_ENABLE_OPENGL_FUNCTIONS_DEBUG
  56. #include <stdio.h>
  57. #define Q_OPENGL_FUNCTIONS_DEBUG \
  58. GLenum error = glGetError(); \
  59. if (error != GL_NO_ERROR) { \
  60. unsigned clamped = qMin(unsigned(error - GL_INVALID_ENUM), 4U); \
  61. const char *errors[] = { "GL_INVALID_ENUM", "GL_INVALID_VALUE", "GL_INVALID_OPERATION", "Unknown" }; \
  62. printf("GL error at %s:%d: %s\n", __FILE__, __LINE__, errors[clamped]); \
  63. int *value = 0; \
  64. *value = 0; \
  65. }
  66. #else
  67. #define Q_OPENGL_FUNCTIONS_DEBUG
  68. #endif
  69. QT_BEGIN_NAMESPACE
  70. struct QOpenGLFunctionsPrivate;
  71. // Undefine any macros from GLEW, qopenglextensions_p.h, etc that
  72. // may interfere with the definition of QOpenGLFunctions.
  73. #undef glBindTexture
  74. #undef glBlendFunc
  75. #undef glClear
  76. #undef glClearColor
  77. #undef glClearStencil
  78. #undef glColorMask
  79. #undef glCopyTexImage2D
  80. #undef glCopyTexSubImage2D
  81. #undef glCullFace
  82. #undef glDeleteTextures
  83. #undef glDepthFunc
  84. #undef glDepthMask
  85. #undef glDisable
  86. #undef glDrawArrays
  87. #undef glDrawElements
  88. #undef glEnable
  89. #undef glFinish
  90. #undef glFlush
  91. #undef glFrontFace
  92. #undef glGenTextures
  93. #undef glGetBooleanv
  94. #undef glGetError
  95. #undef glGetFloatv
  96. #undef glGetIntegerv
  97. #undef glGetString
  98. #undef glGetTexParameterfv
  99. #undef glGetTexParameteriv
  100. #undef glHint
  101. #undef glIsEnabled
  102. #undef glIsTexture
  103. #undef glLineWidth
  104. #undef glPixelStorei
  105. #undef glPolygonOffset
  106. #undef glReadPixels
  107. #undef glScissor
  108. #undef glStencilFunc
  109. #undef glStencilMask
  110. #undef glStencilOp
  111. #undef glTexImage2D
  112. #undef glTexParameterf
  113. #undef glTexParameterfv
  114. #undef glTexParameteri
  115. #undef glTexParameteriv
  116. #undef glTexSubImage2D
  117. #undef glViewport
  118. #undef glActiveTexture
  119. #undef glAttachShader
  120. #undef glBindAttribLocation
  121. #undef glBindBuffer
  122. #undef glBindFramebuffer
  123. #undef glBindRenderbuffer
  124. #undef glBlendColor
  125. #undef glBlendEquation
  126. #undef glBlendEquationSeparate
  127. #undef glBlendFuncSeparate
  128. #undef glBufferData
  129. #undef glBufferSubData
  130. #undef glCheckFramebufferStatus
  131. #undef glClearDepthf
  132. #undef glCompileShader
  133. #undef glCompressedTexImage2D
  134. #undef glCompressedTexSubImage2D
  135. #undef glCreateProgram
  136. #undef glCreateShader
  137. #undef glDeleteBuffers
  138. #undef glDeleteFramebuffers
  139. #undef glDeleteProgram
  140. #undef glDeleteRenderbuffers
  141. #undef glDeleteShader
  142. #undef glDepthRangef
  143. #undef glDetachShader
  144. #undef glDisableVertexAttribArray
  145. #undef glEnableVertexAttribArray
  146. #undef glFramebufferRenderbuffer
  147. #undef glFramebufferTexture2D
  148. #undef glGenBuffers
  149. #undef glGenerateMipmap
  150. #undef glGenFramebuffers
  151. #undef glGenRenderbuffers
  152. #undef glGetActiveAttrib
  153. #undef glGetActiveUniform
  154. #undef glGetAttachedShaders
  155. #undef glGetAttribLocation
  156. #undef glGetBufferParameteriv
  157. #undef glGetFramebufferAttachmentParameteriv
  158. #undef glGetProgramiv
  159. #undef glGetProgramInfoLog
  160. #undef glGetRenderbufferParameteriv
  161. #undef glGetShaderiv
  162. #undef glGetShaderInfoLog
  163. #undef glGetShaderPrecisionFormat
  164. #undef glGetShaderSource
  165. #undef glGetUniformfv
  166. #undef glGetUniformiv
  167. #undef glGetUniformLocation
  168. #undef glGetVertexAttribfv
  169. #undef glGetVertexAttribiv
  170. #undef glGetVertexAttribPointerv
  171. #undef glIsBuffer
  172. #undef glIsFramebuffer
  173. #undef glIsProgram
  174. #undef glIsRenderbuffer
  175. #undef glIsShader
  176. #undef glLinkProgram
  177. #undef glReleaseShaderCompiler
  178. #undef glRenderbufferStorage
  179. #undef glSampleCoverage
  180. #undef glShaderBinary
  181. #undef glShaderSource
  182. #undef glStencilFuncSeparate
  183. #undef glStencilMaskSeparate
  184. #undef glStencilOpSeparate
  185. #undef glUniform1f
  186. #undef glUniform1fv
  187. #undef glUniform1i
  188. #undef glUniform1iv
  189. #undef glUniform2f
  190. #undef glUniform2fv
  191. #undef glUniform2i
  192. #undef glUniform2iv
  193. #undef glUniform3f
  194. #undef glUniform3fv
  195. #undef glUniform3i
  196. #undef glUniform3iv
  197. #undef glUniform4f
  198. #undef glUniform4fv
  199. #undef glUniform4i
  200. #undef glUniform4iv
  201. #undef glUniformMatrix2fv
  202. #undef glUniformMatrix3fv
  203. #undef glUniformMatrix4fv
  204. #undef glUseProgram
  205. #undef glValidateProgram
  206. #undef glVertexAttrib1f
  207. #undef glVertexAttrib1fv
  208. #undef glVertexAttrib2f
  209. #undef glVertexAttrib2fv
  210. #undef glVertexAttrib3f
  211. #undef glVertexAttrib3fv
  212. #undef glVertexAttrib4f
  213. #undef glVertexAttrib4fv
  214. #undef glVertexAttribPointer
  215. #undef glTexLevelParameteriv
  216. class Q_GUI_EXPORT QOpenGLFunctions
  217. {
  218. public:
  219. QOpenGLFunctions();
  220. explicit QOpenGLFunctions(QOpenGLContext *context);
  221. ~QOpenGLFunctions() {}
  222. enum OpenGLFeature
  223. {
  224. Multitexture = 0x0001,
  225. Shaders = 0x0002,
  226. Buffers = 0x0004,
  227. Framebuffers = 0x0008,
  228. BlendColor = 0x0010,
  229. BlendEquation = 0x0020,
  230. BlendEquationSeparate = 0x0040,
  231. BlendFuncSeparate = 0x0080,
  232. BlendSubtract = 0x0100,
  233. CompressedTextures = 0x0200,
  234. Multisample = 0x0400,
  235. StencilSeparate = 0x0800,
  236. NPOTTextures = 0x1000,
  237. NPOTTextureRepeat = 0x2000,
  238. FixedFunctionPipeline = 0x4000,
  239. TextureRGFormats = 0x8000,
  240. MultipleRenderTargets = 0x10000
  241. };
  242. Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature)
  243. QOpenGLFunctions::OpenGLFeatures openGLFeatures() const;
  244. bool hasOpenGLFeature(QOpenGLFunctions::OpenGLFeature feature) const;
  245. void initializeOpenGLFunctions();
  246. #if QT_DEPRECATED_SINCE(5, 0)
  247. QT_DEPRECATED void initializeGLFunctions() { initializeOpenGLFunctions(); }
  248. #endif
  249. // GLES2 + OpenGL1 common subset
  250. void glBindTexture(GLenum target, GLuint texture);
  251. void glBlendFunc(GLenum sfactor, GLenum dfactor);
  252. void glClear(GLbitfield mask);
  253. void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
  254. void glClearStencil(GLint s);
  255. void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
  256. void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
  257. void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
  258. void glCullFace(GLenum mode);
  259. void glDeleteTextures(GLsizei n, const GLuint* textures);
  260. void glDepthFunc(GLenum func);
  261. void glDepthMask(GLboolean flag);
  262. void glDisable(GLenum cap);
  263. void glDrawArrays(GLenum mode, GLint first, GLsizei count);
  264. void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
  265. void glEnable(GLenum cap);
  266. void glFinish();
  267. void glFlush();
  268. void glFrontFace(GLenum mode);
  269. void glGenTextures(GLsizei n, GLuint* textures);
  270. void glGetBooleanv(GLenum pname, GLboolean* params);
  271. GLenum glGetError();
  272. void glGetFloatv(GLenum pname, GLfloat* params);
  273. void glGetIntegerv(GLenum pname, GLint* params);
  274. const GLubyte *glGetString(GLenum name);
  275. void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params);
  276. void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params);
  277. void glHint(GLenum target, GLenum mode);
  278. GLboolean glIsEnabled(GLenum cap);
  279. GLboolean glIsTexture(GLuint texture);
  280. void glLineWidth(GLfloat width);
  281. void glPixelStorei(GLenum pname, GLint param);
  282. void glPolygonOffset(GLfloat factor, GLfloat units);
  283. void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
  284. void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
  285. void glStencilFunc(GLenum func, GLint ref, GLuint mask);
  286. void glStencilMask(GLuint mask);
  287. void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
  288. void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
  289. void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
  290. void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
  291. void glTexParameteri(GLenum target, GLenum pname, GLint param);
  292. void glTexParameteriv(GLenum target, GLenum pname, const GLint* params);
  293. void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
  294. void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
  295. // GL(ES)2
  296. void glActiveTexture(GLenum texture);
  297. void glAttachShader(GLuint program, GLuint shader);
  298. void glBindAttribLocation(GLuint program, GLuint index, const char* name);
  299. void glBindBuffer(GLenum target, GLuint buffer);
  300. void glBindFramebuffer(GLenum target, GLuint framebuffer);
  301. void glBindRenderbuffer(GLenum target, GLuint renderbuffer);
  302. void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
  303. void glBlendEquation(GLenum mode);
  304. void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
  305. void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
  306. void glBufferData(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage);
  307. void glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data);
  308. GLenum glCheckFramebufferStatus(GLenum target);
  309. void glClearDepthf(GLclampf depth);
  310. void glCompileShader(GLuint shader);
  311. void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
  312. void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
  313. GLuint glCreateProgram();
  314. GLuint glCreateShader(GLenum type);
  315. void glDeleteBuffers(GLsizei n, const GLuint* buffers);
  316. void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
  317. void glDeleteProgram(GLuint program);
  318. void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
  319. void glDeleteShader(GLuint shader);
  320. void glDepthRangef(GLclampf zNear, GLclampf zFar);
  321. void glDetachShader(GLuint program, GLuint shader);
  322. void glDisableVertexAttribArray(GLuint index);
  323. void glEnableVertexAttribArray(GLuint index);
  324. void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
  325. void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
  326. void glGenBuffers(GLsizei n, GLuint* buffers);
  327. void glGenerateMipmap(GLenum target);
  328. void glGenFramebuffers(GLsizei n, GLuint* framebuffers);
  329. void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers);
  330. void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
  331. void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
  332. void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
  333. GLint glGetAttribLocation(GLuint program, const char* name);
  334. void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
  335. void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
  336. void glGetProgramiv(GLuint program, GLenum pname, GLint* params);
  337. void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
  338. void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
  339. void glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
  340. void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
  341. void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
  342. void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
  343. void glGetUniformfv(GLuint program, GLint location, GLfloat* params);
  344. void glGetUniformiv(GLuint program, GLint location, GLint* params);
  345. GLint glGetUniformLocation(GLuint program, const char* name);
  346. void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
  347. void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
  348. void glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer);
  349. GLboolean glIsBuffer(GLuint buffer);
  350. GLboolean glIsFramebuffer(GLuint framebuffer);
  351. GLboolean glIsProgram(GLuint program);
  352. GLboolean glIsRenderbuffer(GLuint renderbuffer);
  353. GLboolean glIsShader(GLuint shader);
  354. void glLinkProgram(GLuint program);
  355. void glReleaseShaderCompiler();
  356. void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
  357. void glSampleCoverage(GLclampf value, GLboolean invert);
  358. void glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
  359. void glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length);
  360. void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
  361. void glStencilMaskSeparate(GLenum face, GLuint mask);
  362. void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
  363. void glUniform1f(GLint location, GLfloat x);
  364. void glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
  365. void glUniform1i(GLint location, GLint x);
  366. void glUniform1iv(GLint location, GLsizei count, const GLint* v);
  367. void glUniform2f(GLint location, GLfloat x, GLfloat y);
  368. void glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
  369. void glUniform2i(GLint location, GLint x, GLint y);
  370. void glUniform2iv(GLint location, GLsizei count, const GLint* v);
  371. void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
  372. void glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
  373. void glUniform3i(GLint location, GLint x, GLint y, GLint z);
  374. void glUniform3iv(GLint location, GLsizei count, const GLint* v);
  375. void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
  376. void glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
  377. void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
  378. void glUniform4iv(GLint location, GLsizei count, const GLint* v);
  379. void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
  380. void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
  381. void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
  382. void glUseProgram(GLuint program);
  383. void glValidateProgram(GLuint program);
  384. void glVertexAttrib1f(GLuint indx, GLfloat x);
  385. void glVertexAttrib1fv(GLuint indx, const GLfloat* values);
  386. void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
  387. void glVertexAttrib2fv(GLuint indx, const GLfloat* values);
  388. void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
  389. void glVertexAttrib3fv(GLuint indx, const GLfloat* values);
  390. void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
  391. void glVertexAttrib4fv(GLuint indx, const GLfloat* values);
  392. void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
  393. protected:
  394. QOpenGLFunctionsPrivate *d_ptr;
  395. static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != Q_NULLPTR; }
  396. };
  397. Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLFunctions::OpenGLFeatures)
  398. #define QT_OPENGL_DECLARE_FUNCTIONS(ret, name, args) \
  399. ret (QOPENGLF_APIENTRYP name)args;
  400. #define QT_OPENGL_COUNT_FUNCTIONS(ret, name, args) +1
  401. #define QT_OPENGL_DECLARE(FUNCTIONS) \
  402. public: \
  403. struct Functions { \
  404. FUNCTIONS(QT_OPENGL_DECLARE_FUNCTIONS) \
  405. }; \
  406. union { \
  407. QFunctionPointer functions[FUNCTIONS(QT_OPENGL_COUNT_FUNCTIONS)]; \
  408. Functions f; \
  409. }; \
  410. private: \
  411. void init(QOpenGLContext *context);
  412. struct QOpenGLFunctionsPrivate
  413. {
  414. QOpenGLFunctionsPrivate(QOpenGLContext *ctx);
  415. #define QT_OPENGL_FUNCTIONS(F) \
  416. F(void, BindTexture, (GLenum target, GLuint texture)) \
  417. F(void, BlendFunc, (GLenum sfactor, GLenum dfactor)) \
  418. F(void, Clear, (GLbitfield mask)) \
  419. F(void, ClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) \
  420. F(void, ClearDepthf, (GLclampf depth)) \
  421. F(void, ClearStencil, (GLint s)) \
  422. F(void, ColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)) \
  423. F(void, CopyTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)) \
  424. F(void, CopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)) \
  425. F(void, CullFace, (GLenum mode)) \
  426. F(void, DeleteTextures, (GLsizei n, const GLuint* textures)) \
  427. F(void, DepthFunc, (GLenum func)) \
  428. F(void, DepthMask, (GLboolean flag)) \
  429. F(void, DepthRangef, (GLclampf nearVal, GLclampf farVal)) \
  430. F(void, Disable, (GLenum cap)) \
  431. F(void, DrawArrays, (GLenum mode, GLint first, GLsizei count)) \
  432. F(void, DrawElements, (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)) \
  433. F(void, Enable, (GLenum cap)) \
  434. F(void, Finish, ()) \
  435. F(void, Flush, ()) \
  436. F(void, FrontFace, (GLenum mode)) \
  437. F(void, GenTextures, (GLsizei n, GLuint* textures)) \
  438. F(void, GetBooleanv, (GLenum pname, GLboolean* params)) \
  439. F(GLenum, GetError, ()) \
  440. F(void, GetFloatv, (GLenum pname, GLfloat* params)) \
  441. F(void, GetIntegerv, (GLenum pname, GLint* params)) \
  442. F(const GLubyte *, GetString, (GLenum name)) \
  443. F(void, GetTexParameterfv, (GLenum target, GLenum pname, GLfloat* params)) \
  444. F(void, GetTexParameteriv, (GLenum target, GLenum pname, GLint* params)) \
  445. F(void, Hint, (GLenum target, GLenum mode)) \
  446. F(GLboolean, IsEnabled, (GLenum cap)) \
  447. F(GLboolean, IsTexture, (GLuint texture)) \
  448. F(void, LineWidth, (GLfloat width)) \
  449. F(void, PixelStorei, (GLenum pname, GLint param)) \
  450. F(void, PolygonOffset, (GLfloat factor, GLfloat units)) \
  451. F(void, ReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)) \
  452. F(void, Scissor, (GLint x, GLint y, GLsizei width, GLsizei height)) \
  453. F(void, StencilFunc, (GLenum func, GLint ref, GLuint mask)) \
  454. F(void, StencilMask, (GLuint mask)) \
  455. F(void, StencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) \
  456. F(void, TexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)) \
  457. F(void, TexParameterf, (GLenum target, GLenum pname, GLfloat param)) \
  458. F(void, TexParameterfv, (GLenum target, GLenum pname, const GLfloat* params)) \
  459. F(void, TexParameteri, (GLenum target, GLenum pname, GLint param)) \
  460. F(void, TexParameteriv, (GLenum target, GLenum pname, const GLint* params)) \
  461. F(void, TexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)) \
  462. F(void, Viewport, (GLint x, GLint y, GLsizei width, GLsizei height)) \
  463. F(void, ActiveTexture, (GLenum texture)) \
  464. F(void, AttachShader, (GLuint program, GLuint shader)) \
  465. F(void, BindAttribLocation, (GLuint program, GLuint index, const char* name)) \
  466. F(void, BindBuffer, (GLenum target, GLuint buffer)) \
  467. F(void, BindFramebuffer, (GLenum target, GLuint framebuffer)) \
  468. F(void, BindRenderbuffer, (GLenum target, GLuint renderbuffer)) \
  469. F(void, BlendColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) \
  470. F(void, BlendEquation, (GLenum mode)) \
  471. F(void, BlendEquationSeparate, (GLenum modeRGB, GLenum modeAlpha)) \
  472. F(void, BlendFuncSeparate, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)) \
  473. F(void, BufferData, (GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage)) \
  474. F(void, BufferSubData, (GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data)) \
  475. F(GLenum, CheckFramebufferStatus, (GLenum target)) \
  476. F(void, CompileShader, (GLuint shader)) \
  477. F(void, CompressedTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)) \
  478. F(void, CompressedTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)) \
  479. F(GLuint, CreateProgram, ()) \
  480. F(GLuint, CreateShader, (GLenum type)) \
  481. F(void, DeleteBuffers, (GLsizei n, const GLuint* buffers)) \
  482. F(void, DeleteFramebuffers, (GLsizei n, const GLuint* framebuffers)) \
  483. F(void, DeleteProgram, (GLuint program)) \
  484. F(void, DeleteRenderbuffers, (GLsizei n, const GLuint* renderbuffers)) \
  485. F(void, DeleteShader, (GLuint shader)) \
  486. F(void, DetachShader, (GLuint program, GLuint shader)) \
  487. F(void, DisableVertexAttribArray, (GLuint index)) \
  488. F(void, EnableVertexAttribArray, (GLuint index)) \
  489. F(void, FramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)) \
  490. F(void, FramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)) \
  491. F(void, GenBuffers, (GLsizei n, GLuint* buffers)) \
  492. F(void, GenerateMipmap, (GLenum target)) \
  493. F(void, GenFramebuffers, (GLsizei n, GLuint* framebuffers)) \
  494. F(void, GenRenderbuffers, (GLsizei n, GLuint* renderbuffers)) \
  495. F(void, GetActiveAttrib, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)) \
  496. F(void, GetActiveUniform, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)) \
  497. F(void, GetAttachedShaders, (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)) \
  498. F(GLint, GetAttribLocation, (GLuint program, const char* name)) \
  499. F(void, GetBufferParameteriv, (GLenum target, GLenum pname, GLint* params)) \
  500. F(void, GetFramebufferAttachmentParameteriv, (GLenum target, GLenum attachment, GLenum pname, GLint* params)) \
  501. F(void, GetProgramiv, (GLuint program, GLenum pname, GLint* params)) \
  502. F(void, GetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)) \
  503. F(void, GetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint* params)) \
  504. F(void, GetShaderiv, (GLuint shader, GLenum pname, GLint* params)) \
  505. F(void, GetShaderInfoLog, (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)) \
  506. F(void, GetShaderPrecisionFormat, (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)) \
  507. F(void, GetShaderSource, (GLuint shader, GLsizei bufsize, GLsizei* length, char* source)) \
  508. F(void, GetUniformfv, (GLuint program, GLint location, GLfloat* params)) \
  509. F(void, GetUniformiv, (GLuint program, GLint location, GLint* params)) \
  510. F(GLint, GetUniformLocation, (GLuint program, const char* name)) \
  511. F(void, GetVertexAttribfv, (GLuint index, GLenum pname, GLfloat* params)) \
  512. F(void, GetVertexAttribiv, (GLuint index, GLenum pname, GLint* params)) \
  513. F(void, GetVertexAttribPointerv, (GLuint index, GLenum pname, void** pointer)) \
  514. F(GLboolean, IsBuffer, (GLuint buffer)) \
  515. F(GLboolean, IsFramebuffer, (GLuint framebuffer)) \
  516. F(GLboolean, IsProgram, (GLuint program)) \
  517. F(GLboolean, IsRenderbuffer, (GLuint renderbuffer)) \
  518. F(GLboolean, IsShader, (GLuint shader)) \
  519. F(void, LinkProgram, (GLuint program)) \
  520. F(void, ReleaseShaderCompiler, ()) \
  521. F(void, RenderbufferStorage, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height)) \
  522. F(void, SampleCoverage, (GLclampf value, GLboolean invert)) \
  523. F(void, ShaderBinary, (GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)) \
  524. F(void, ShaderSource, (GLuint shader, GLsizei count, const char** string, const GLint* length)) \
  525. F(void, StencilFuncSeparate, (GLenum face, GLenum func, GLint ref, GLuint mask)) \
  526. F(void, StencilMaskSeparate, (GLenum face, GLuint mask)) \
  527. F(void, StencilOpSeparate, (GLenum face, GLenum fail, GLenum zfail, GLenum zpass)) \
  528. F(void, Uniform1f, (GLint location, GLfloat x)) \
  529. F(void, Uniform1fv, (GLint location, GLsizei count, const GLfloat* v)) \
  530. F(void, Uniform1i, (GLint location, GLint x)) \
  531. F(void, Uniform1iv, (GLint location, GLsizei count, const GLint* v)) \
  532. F(void, Uniform2f, (GLint location, GLfloat x, GLfloat y)) \
  533. F(void, Uniform2fv, (GLint location, GLsizei count, const GLfloat* v)) \
  534. F(void, Uniform2i, (GLint location, GLint x, GLint y)) \
  535. F(void, Uniform2iv, (GLint location, GLsizei count, const GLint* v)) \
  536. F(void, Uniform3f, (GLint location, GLfloat x, GLfloat y, GLfloat z)) \
  537. F(void, Uniform3fv, (GLint location, GLsizei count, const GLfloat* v)) \
  538. F(void, Uniform3i, (GLint location, GLint x, GLint y, GLint z)) \
  539. F(void, Uniform3iv, (GLint location, GLsizei count, const GLint* v)) \
  540. F(void, Uniform4f, (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)) \
  541. F(void, Uniform4fv, (GLint location, GLsizei count, const GLfloat* v)) \
  542. F(void, Uniform4i, (GLint location, GLint x, GLint y, GLint z, GLint w)) \
  543. F(void, Uniform4iv, (GLint location, GLsizei count, const GLint* v)) \
  544. F(void, UniformMatrix2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)) \
  545. F(void, UniformMatrix3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)) \
  546. F(void, UniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)) \
  547. F(void, UseProgram, (GLuint program)) \
  548. F(void, ValidateProgram, (GLuint program)) \
  549. F(void, VertexAttrib1f, (GLuint indx, GLfloat x)) \
  550. F(void, VertexAttrib1fv, (GLuint indx, const GLfloat* values)) \
  551. F(void, VertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y)) \
  552. F(void, VertexAttrib2fv, (GLuint indx, const GLfloat* values)) \
  553. F(void, VertexAttrib3f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z)) \
  554. F(void, VertexAttrib3fv, (GLuint indx, const GLfloat* values)) \
  555. F(void, VertexAttrib4f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)) \
  556. F(void, VertexAttrib4fv, (GLuint indx, const GLfloat* values)) \
  557. F(void, VertexAttribPointer, (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)) \
  558. F(void, ClearDepth, (GLdouble depth)) \
  559. F(void, DepthRange, (GLdouble zNear, GLdouble zFar)) \
  560. QT_OPENGL_DECLARE(QT_OPENGL_FUNCTIONS)
  561. };
  562. // GLES2 + OpenGL1 common subset
  563. inline void QOpenGLFunctions::glBindTexture(GLenum target, GLuint texture)
  564. {
  565. #ifdef QT_OPENGL_ES_2
  566. ::glBindTexture(target, texture);
  567. #else
  568. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  569. d_ptr->f.BindTexture(target, texture);
  570. #endif
  571. Q_OPENGL_FUNCTIONS_DEBUG
  572. }
  573. inline void QOpenGLFunctions::glBlendFunc(GLenum sfactor, GLenum dfactor)
  574. {
  575. #ifdef QT_OPENGL_ES_2
  576. ::glBlendFunc(sfactor, dfactor);
  577. #else
  578. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  579. d_ptr->f.BlendFunc(sfactor, dfactor);
  580. #endif
  581. Q_OPENGL_FUNCTIONS_DEBUG
  582. }
  583. inline void QOpenGLFunctions::glClear(GLbitfield mask)
  584. {
  585. #ifdef QT_OPENGL_ES_2
  586. ::glClear(mask);
  587. #else
  588. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  589. d_ptr->f.Clear(mask);
  590. #endif
  591. Q_OPENGL_FUNCTIONS_DEBUG
  592. }
  593. inline void QOpenGLFunctions::glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
  594. {
  595. #ifdef QT_OPENGL_ES_2
  596. ::glClearColor(red, green, blue, alpha);
  597. #else
  598. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  599. d_ptr->f.ClearColor(red, green, blue, alpha);
  600. #endif
  601. Q_OPENGL_FUNCTIONS_DEBUG
  602. }
  603. inline void QOpenGLFunctions::glClearStencil(GLint s)
  604. {
  605. #ifdef QT_OPENGL_ES_2
  606. ::glClearStencil(s);
  607. #else
  608. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  609. d_ptr->f.ClearStencil(s);
  610. #endif
  611. Q_OPENGL_FUNCTIONS_DEBUG
  612. }
  613. inline void QOpenGLFunctions::glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
  614. {
  615. #ifdef QT_OPENGL_ES_2
  616. ::glColorMask(red, green, blue, alpha);
  617. #else
  618. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  619. d_ptr->f.ColorMask(red, green, blue, alpha);
  620. #endif
  621. Q_OPENGL_FUNCTIONS_DEBUG
  622. }
  623. inline void QOpenGLFunctions::glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
  624. {
  625. #ifdef QT_OPENGL_ES_2
  626. ::glCopyTexImage2D(target, level, internalformat, x, y, width,height, border);
  627. #else
  628. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  629. d_ptr->f.CopyTexImage2D(target, level, internalformat, x, y, width,height, border);
  630. #endif
  631. Q_OPENGL_FUNCTIONS_DEBUG
  632. }
  633. inline void QOpenGLFunctions::glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
  634. {
  635. #ifdef QT_OPENGL_ES_2
  636. ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
  637. #else
  638. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  639. d_ptr->f.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
  640. #endif
  641. Q_OPENGL_FUNCTIONS_DEBUG
  642. }
  643. inline void QOpenGLFunctions::glCullFace(GLenum mode)
  644. {
  645. #ifdef QT_OPENGL_ES_2
  646. ::glCullFace(mode);
  647. #else
  648. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  649. d_ptr->f.CullFace(mode);
  650. #endif
  651. Q_OPENGL_FUNCTIONS_DEBUG
  652. }
  653. inline void QOpenGLFunctions::glDeleteTextures(GLsizei n, const GLuint* textures)
  654. {
  655. #ifdef QT_OPENGL_ES_2
  656. ::glDeleteTextures(n, textures);
  657. #else
  658. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  659. d_ptr->f.DeleteTextures(n, textures);
  660. #endif
  661. Q_OPENGL_FUNCTIONS_DEBUG
  662. }
  663. inline void QOpenGLFunctions::glDepthFunc(GLenum func)
  664. {
  665. #ifdef QT_OPENGL_ES_2
  666. ::glDepthFunc(func);
  667. #else
  668. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  669. d_ptr->f.DepthFunc(func);
  670. #endif
  671. Q_OPENGL_FUNCTIONS_DEBUG
  672. }
  673. inline void QOpenGLFunctions::glDepthMask(GLboolean flag)
  674. {
  675. #ifdef QT_OPENGL_ES_2
  676. ::glDepthMask(flag);
  677. #else
  678. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  679. d_ptr->f.DepthMask(flag);
  680. #endif
  681. Q_OPENGL_FUNCTIONS_DEBUG
  682. }
  683. inline void QOpenGLFunctions::glDisable(GLenum cap)
  684. {
  685. #ifdef QT_OPENGL_ES_2
  686. ::glDisable(cap);
  687. #else
  688. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  689. d_ptr->f.Disable(cap);
  690. #endif
  691. Q_OPENGL_FUNCTIONS_DEBUG
  692. }
  693. inline void QOpenGLFunctions::glDrawArrays(GLenum mode, GLint first, GLsizei count)
  694. {
  695. #ifdef QT_OPENGL_ES_2
  696. ::glDrawArrays(mode, first, count);
  697. #else
  698. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  699. d_ptr->f.DrawArrays(mode, first, count);
  700. #endif
  701. Q_OPENGL_FUNCTIONS_DEBUG
  702. }
  703. inline void QOpenGLFunctions::glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
  704. {
  705. #ifdef QT_OPENGL_ES_2
  706. ::glDrawElements(mode, count, type, indices);
  707. #else
  708. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  709. d_ptr->f.DrawElements(mode, count, type, indices);
  710. #endif
  711. Q_OPENGL_FUNCTIONS_DEBUG
  712. }
  713. inline void QOpenGLFunctions::glEnable(GLenum cap)
  714. {
  715. #ifdef QT_OPENGL_ES_2
  716. ::glEnable(cap);
  717. #else
  718. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  719. d_ptr->f.Enable(cap);
  720. #endif
  721. Q_OPENGL_FUNCTIONS_DEBUG
  722. }
  723. inline void QOpenGLFunctions::glFinish()
  724. {
  725. #ifdef QT_OPENGL_ES_2
  726. ::glFinish();
  727. #else
  728. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  729. d_ptr->f.Finish();
  730. #endif
  731. Q_OPENGL_FUNCTIONS_DEBUG
  732. }
  733. inline void QOpenGLFunctions::glFlush()
  734. {
  735. #ifdef QT_OPENGL_ES_2
  736. ::glFlush();
  737. #else
  738. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  739. d_ptr->f.Flush();
  740. #endif
  741. Q_OPENGL_FUNCTIONS_DEBUG
  742. }
  743. inline void QOpenGLFunctions::glFrontFace(GLenum mode)
  744. {
  745. #ifdef QT_OPENGL_ES_2
  746. ::glFrontFace(mode);
  747. #else
  748. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  749. d_ptr->f.FrontFace(mode);
  750. #endif
  751. Q_OPENGL_FUNCTIONS_DEBUG
  752. }
  753. inline void QOpenGLFunctions::glGenTextures(GLsizei n, GLuint* textures)
  754. {
  755. #ifdef QT_OPENGL_ES_2
  756. ::glGenTextures(n, textures);
  757. #else
  758. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  759. d_ptr->f.GenTextures(n, textures);
  760. #endif
  761. Q_OPENGL_FUNCTIONS_DEBUG
  762. }
  763. inline void QOpenGLFunctions::glGetBooleanv(GLenum pname, GLboolean* params)
  764. {
  765. #ifdef QT_OPENGL_ES_2
  766. ::glGetBooleanv(pname, params);
  767. #else
  768. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  769. d_ptr->f.GetBooleanv(pname, params);
  770. #endif
  771. Q_OPENGL_FUNCTIONS_DEBUG
  772. }
  773. inline GLenum QOpenGLFunctions::glGetError()
  774. {
  775. #ifdef QT_OPENGL_ES_2
  776. GLenum result = ::glGetError();
  777. #else
  778. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  779. GLenum result = d_ptr->f.GetError();
  780. #endif
  781. return result;
  782. }
  783. inline void QOpenGLFunctions::glGetFloatv(GLenum pname, GLfloat* params)
  784. {
  785. #ifdef QT_OPENGL_ES_2
  786. ::glGetFloatv(pname, params);
  787. #else
  788. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  789. d_ptr->f.GetFloatv(pname, params);
  790. #endif
  791. Q_OPENGL_FUNCTIONS_DEBUG
  792. }
  793. inline void QOpenGLFunctions::glGetIntegerv(GLenum pname, GLint* params)
  794. {
  795. #ifdef QT_OPENGL_ES_2
  796. ::glGetIntegerv(pname, params);
  797. #else
  798. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  799. d_ptr->f.GetIntegerv(pname, params);
  800. #endif
  801. Q_OPENGL_FUNCTIONS_DEBUG
  802. }
  803. inline const GLubyte *QOpenGLFunctions::glGetString(GLenum name)
  804. {
  805. #ifdef QT_OPENGL_ES_2
  806. const GLubyte *result = ::glGetString(name);
  807. #else
  808. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  809. const GLubyte *result = d_ptr->f.GetString(name);
  810. #endif
  811. Q_OPENGL_FUNCTIONS_DEBUG
  812. return result;
  813. }
  814. inline void QOpenGLFunctions::glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
  815. {
  816. #ifdef QT_OPENGL_ES_2
  817. ::glGetTexParameterfv(target, pname, params);
  818. #else
  819. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  820. d_ptr->f.GetTexParameterfv(target, pname, params);
  821. #endif
  822. Q_OPENGL_FUNCTIONS_DEBUG
  823. }
  824. inline void QOpenGLFunctions::glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
  825. {
  826. #ifdef QT_OPENGL_ES_2
  827. ::glGetTexParameteriv(target, pname, params);
  828. #else
  829. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  830. d_ptr->f.GetTexParameteriv(target, pname, params);
  831. #endif
  832. Q_OPENGL_FUNCTIONS_DEBUG
  833. }
  834. inline void QOpenGLFunctions::glHint(GLenum target, GLenum mode)
  835. {
  836. #ifdef QT_OPENGL_ES_2
  837. ::glHint(target, mode);
  838. #else
  839. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  840. d_ptr->f.Hint(target, mode);
  841. #endif
  842. Q_OPENGL_FUNCTIONS_DEBUG
  843. }
  844. inline GLboolean QOpenGLFunctions::glIsEnabled(GLenum cap)
  845. {
  846. #ifdef QT_OPENGL_ES_2
  847. GLboolean result = ::glIsEnabled(cap);
  848. #else
  849. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  850. GLboolean result = d_ptr->f.IsEnabled(cap);
  851. #endif
  852. Q_OPENGL_FUNCTIONS_DEBUG
  853. return result;
  854. }
  855. inline GLboolean QOpenGLFunctions::glIsTexture(GLuint texture)
  856. {
  857. #ifdef QT_OPENGL_ES_2
  858. GLboolean result = ::glIsTexture(texture);
  859. #else
  860. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  861. GLboolean result = d_ptr->f.IsTexture(texture);
  862. #endif
  863. Q_OPENGL_FUNCTIONS_DEBUG
  864. return result;
  865. }
  866. inline void QOpenGLFunctions::glLineWidth(GLfloat width)
  867. {
  868. #ifdef QT_OPENGL_ES_2
  869. ::glLineWidth(width);
  870. #else
  871. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  872. d_ptr->f.LineWidth(width);
  873. #endif
  874. Q_OPENGL_FUNCTIONS_DEBUG
  875. }
  876. inline void QOpenGLFunctions::glPixelStorei(GLenum pname, GLint param)
  877. {
  878. #ifdef QT_OPENGL_ES_2
  879. ::glPixelStorei(pname, param);
  880. #else
  881. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  882. d_ptr->f.PixelStorei(pname, param);
  883. #endif
  884. Q_OPENGL_FUNCTIONS_DEBUG
  885. }
  886. inline void QOpenGLFunctions::glPolygonOffset(GLfloat factor, GLfloat units)
  887. {
  888. #ifdef QT_OPENGL_ES_2
  889. ::glPolygonOffset(factor, units);
  890. #else
  891. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  892. d_ptr->f.PolygonOffset(factor, units);
  893. #endif
  894. Q_OPENGL_FUNCTIONS_DEBUG
  895. }
  896. inline void QOpenGLFunctions::glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
  897. {
  898. #ifdef QT_OPENGL_ES_2
  899. ::glReadPixels(x, y, width, height, format, type, pixels);
  900. #else
  901. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  902. d_ptr->f.ReadPixels(x, y, width, height, format, type, pixels);
  903. #endif
  904. Q_OPENGL_FUNCTIONS_DEBUG
  905. }
  906. inline void QOpenGLFunctions::glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
  907. {
  908. #ifdef QT_OPENGL_ES_2
  909. ::glScissor(x, y, width, height);
  910. #else
  911. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  912. d_ptr->f.Scissor(x, y, width, height);
  913. #endif
  914. Q_OPENGL_FUNCTIONS_DEBUG
  915. }
  916. inline void QOpenGLFunctions::glStencilFunc(GLenum func, GLint ref, GLuint mask)
  917. {
  918. #ifdef QT_OPENGL_ES_2
  919. ::glStencilFunc(func, ref, mask);
  920. #else
  921. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  922. d_ptr->f.StencilFunc(func, ref, mask);
  923. #endif
  924. Q_OPENGL_FUNCTIONS_DEBUG
  925. }
  926. inline void QOpenGLFunctions::glStencilMask(GLuint mask)
  927. {
  928. #ifdef QT_OPENGL_ES_2
  929. ::glStencilMask(mask);
  930. #else
  931. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  932. d_ptr->f.StencilMask(mask);
  933. #endif
  934. Q_OPENGL_FUNCTIONS_DEBUG
  935. }
  936. inline void QOpenGLFunctions::glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
  937. {
  938. #ifdef QT_OPENGL_ES_2
  939. ::glStencilOp(fail, zfail, zpass);
  940. #else
  941. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  942. d_ptr->f.StencilOp(fail, zfail, zpass);
  943. #endif
  944. Q_OPENGL_FUNCTIONS_DEBUG
  945. }
  946. inline void QOpenGLFunctions::glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
  947. {
  948. #ifdef QT_OPENGL_ES_2
  949. ::glTexImage2D(target, level, internalformat, width,height, border, format, type, pixels);
  950. #else
  951. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  952. d_ptr->f.TexImage2D(target, level, internalformat, width,height, border, format, type, pixels);
  953. #endif
  954. Q_OPENGL_FUNCTIONS_DEBUG
  955. }
  956. inline void QOpenGLFunctions::glTexParameterf(GLenum target, GLenum pname, GLfloat param)
  957. {
  958. #ifdef QT_OPENGL_ES_2
  959. ::glTexParameterf(target, pname, param);
  960. #else
  961. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  962. d_ptr->f.TexParameterf(target, pname, param);
  963. #endif
  964. Q_OPENGL_FUNCTIONS_DEBUG
  965. }
  966. inline void QOpenGLFunctions::glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
  967. {
  968. #ifdef QT_OPENGL_ES_2
  969. ::glTexParameterfv(target, pname, params);
  970. #else
  971. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  972. d_ptr->f.TexParameterfv(target, pname, params);
  973. #endif
  974. Q_OPENGL_FUNCTIONS_DEBUG
  975. }
  976. inline void QOpenGLFunctions::glTexParameteri(GLenum target, GLenum pname, GLint param)
  977. {
  978. #ifdef QT_OPENGL_ES_2
  979. ::glTexParameteri(target, pname, param);
  980. #else
  981. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  982. d_ptr->f.TexParameteri(target, pname, param);
  983. #endif
  984. Q_OPENGL_FUNCTIONS_DEBUG
  985. }
  986. inline void QOpenGLFunctions::glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
  987. {
  988. #ifdef QT_OPENGL_ES_2
  989. ::glTexParameteriv(target, pname, params);
  990. #else
  991. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  992. d_ptr->f.TexParameteriv(target, pname, params);
  993. #endif
  994. Q_OPENGL_FUNCTIONS_DEBUG
  995. }
  996. inline void QOpenGLFunctions::glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
  997. {
  998. #ifdef QT_OPENGL_ES_2
  999. ::glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
  1000. #else
  1001. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1002. d_ptr->f.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
  1003. #endif
  1004. Q_OPENGL_FUNCTIONS_DEBUG
  1005. }
  1006. inline void QOpenGLFunctions::glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
  1007. {
  1008. #ifdef QT_OPENGL_ES_2
  1009. ::glViewport(x, y, width, height);
  1010. #else
  1011. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1012. d_ptr->f.Viewport(x, y, width, height);
  1013. #endif
  1014. Q_OPENGL_FUNCTIONS_DEBUG
  1015. }
  1016. // GL(ES)2
  1017. inline void QOpenGLFunctions::glActiveTexture(GLenum texture)
  1018. {
  1019. #ifdef QT_OPENGL_ES_2
  1020. ::glActiveTexture(texture);
  1021. #else
  1022. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1023. d_ptr->f.ActiveTexture(texture);
  1024. #endif
  1025. Q_OPENGL_FUNCTIONS_DEBUG
  1026. }
  1027. inline void QOpenGLFunctions::glAttachShader(GLuint program, GLuint shader)
  1028. {
  1029. #ifdef QT_OPENGL_ES_2
  1030. ::glAttachShader(program, shader);
  1031. #else
  1032. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1033. d_ptr->f.AttachShader(program, shader);
  1034. #endif
  1035. Q_OPENGL_FUNCTIONS_DEBUG
  1036. }
  1037. inline void QOpenGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name)
  1038. {
  1039. #ifdef QT_OPENGL_ES_2
  1040. ::glBindAttribLocation(program, index, name);
  1041. #else
  1042. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1043. d_ptr->f.BindAttribLocation(program, index, name);
  1044. #endif
  1045. Q_OPENGL_FUNCTIONS_DEBUG
  1046. }
  1047. inline void QOpenGLFunctions::glBindBuffer(GLenum target, GLuint buffer)
  1048. {
  1049. #ifdef QT_OPENGL_ES_2
  1050. ::glBindBuffer(target, buffer);
  1051. #else
  1052. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1053. d_ptr->f.BindBuffer(target, buffer);
  1054. #endif
  1055. Q_OPENGL_FUNCTIONS_DEBUG
  1056. }
  1057. inline void QOpenGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer)
  1058. {
  1059. if (framebuffer == 0)
  1060. framebuffer = QOpenGLContext::currentContext()->defaultFramebufferObject();
  1061. #ifdef QT_OPENGL_ES_2
  1062. ::glBindFramebuffer(target, framebuffer);
  1063. #else
  1064. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1065. d_ptr->f.BindFramebuffer(target, framebuffer);
  1066. #endif
  1067. Q_OPENGL_FUNCTIONS_DEBUG
  1068. }
  1069. inline void QOpenGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer)
  1070. {
  1071. #ifdef QT_OPENGL_ES_2
  1072. ::glBindRenderbuffer(target, renderbuffer);
  1073. #else
  1074. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1075. d_ptr->f.BindRenderbuffer(target, renderbuffer);
  1076. #endif
  1077. Q_OPENGL_FUNCTIONS_DEBUG
  1078. }
  1079. inline void QOpenGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
  1080. {
  1081. #ifdef QT_OPENGL_ES_2
  1082. ::glBlendColor(red, green, blue, alpha);
  1083. #else
  1084. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1085. d_ptr->f.BlendColor(red, green, blue, alpha);
  1086. #endif
  1087. Q_OPENGL_FUNCTIONS_DEBUG
  1088. }
  1089. inline void QOpenGLFunctions::glBlendEquation(GLenum mode)
  1090. {
  1091. #ifdef QT_OPENGL_ES_2
  1092. ::glBlendEquation(mode);
  1093. #else
  1094. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1095. d_ptr->f.BlendEquation(mode);
  1096. #endif
  1097. Q_OPENGL_FUNCTIONS_DEBUG
  1098. }
  1099. inline void QOpenGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
  1100. {
  1101. #ifdef QT_OPENGL_ES_2
  1102. ::glBlendEquationSeparate(modeRGB, modeAlpha);
  1103. #else
  1104. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1105. d_ptr->f.BlendEquationSeparate(modeRGB, modeAlpha);
  1106. #endif
  1107. Q_OPENGL_FUNCTIONS_DEBUG
  1108. }
  1109. inline void QOpenGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
  1110. {
  1111. #ifdef QT_OPENGL_ES_2
  1112. ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
  1113. #else
  1114. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1115. d_ptr->f.BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
  1116. #endif
  1117. Q_OPENGL_FUNCTIONS_DEBUG
  1118. }
  1119. inline void QOpenGLFunctions::glBufferData(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage)
  1120. {
  1121. #ifdef QT_OPENGL_ES_2
  1122. ::glBufferData(target, size, data, usage);
  1123. #else
  1124. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1125. d_ptr->f.BufferData(target, size, data, usage);
  1126. #endif
  1127. Q_OPENGL_FUNCTIONS_DEBUG
  1128. }
  1129. inline void QOpenGLFunctions::glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data)
  1130. {
  1131. #ifdef QT_OPENGL_ES_2
  1132. ::glBufferSubData(target, offset, size, data);
  1133. #else
  1134. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1135. d_ptr->f.BufferSubData(target, offset, size, data);
  1136. #endif
  1137. Q_OPENGL_FUNCTIONS_DEBUG
  1138. }
  1139. inline GLenum QOpenGLFunctions::glCheckFramebufferStatus(GLenum target)
  1140. {
  1141. #ifdef QT_OPENGL_ES_2
  1142. GLenum result = ::glCheckFramebufferStatus(target);
  1143. #else
  1144. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1145. GLenum result = d_ptr->f.CheckFramebufferStatus(target);
  1146. #endif
  1147. Q_OPENGL_FUNCTIONS_DEBUG
  1148. return result;
  1149. }
  1150. inline void QOpenGLFunctions::glClearDepthf(GLclampf depth)
  1151. {
  1152. #ifndef QT_OPENGL_ES
  1153. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1154. d_ptr->f.ClearDepthf(depth);
  1155. #else
  1156. ::glClearDepthf(depth);
  1157. #endif
  1158. Q_OPENGL_FUNCTIONS_DEBUG
  1159. }
  1160. inline void QOpenGLFunctions::glCompileShader(GLuint shader)
  1161. {
  1162. #ifdef QT_OPENGL_ES_2
  1163. ::glCompileShader(shader);
  1164. #else
  1165. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1166. d_ptr->f.CompileShader(shader);
  1167. #endif
  1168. Q_OPENGL_FUNCTIONS_DEBUG
  1169. }
  1170. inline void QOpenGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
  1171. {
  1172. #ifdef QT_OPENGL_ES_2
  1173. ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
  1174. #else
  1175. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1176. d_ptr->f.CompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
  1177. #endif
  1178. Q_OPENGL_FUNCTIONS_DEBUG
  1179. }
  1180. inline void QOpenGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
  1181. {
  1182. #ifdef QT_OPENGL_ES_2
  1183. ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
  1184. #else
  1185. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1186. d_ptr->f.CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
  1187. #endif
  1188. Q_OPENGL_FUNCTIONS_DEBUG
  1189. }
  1190. inline GLuint QOpenGLFunctions::glCreateProgram()
  1191. {
  1192. #ifdef QT_OPENGL_ES_2
  1193. GLuint result = ::glCreateProgram();
  1194. #else
  1195. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1196. GLuint result = d_ptr->f.CreateProgram();
  1197. #endif
  1198. Q_OPENGL_FUNCTIONS_DEBUG
  1199. return result;
  1200. }
  1201. inline GLuint QOpenGLFunctions::glCreateShader(GLenum type)
  1202. {
  1203. #ifdef QT_OPENGL_ES_2
  1204. GLuint result = ::glCreateShader(type);
  1205. #else
  1206. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1207. GLuint result = d_ptr->f.CreateShader(type);
  1208. #endif
  1209. Q_OPENGL_FUNCTIONS_DEBUG
  1210. return result;
  1211. }
  1212. inline void QOpenGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers)
  1213. {
  1214. #ifdef QT_OPENGL_ES_2
  1215. ::glDeleteBuffers(n, buffers);
  1216. #else
  1217. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1218. d_ptr->f.DeleteBuffers(n, buffers);
  1219. #endif
  1220. Q_OPENGL_FUNCTIONS_DEBUG
  1221. }
  1222. inline void QOpenGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
  1223. {
  1224. #ifdef QT_OPENGL_ES_2
  1225. ::glDeleteFramebuffers(n, framebuffers);
  1226. #else
  1227. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1228. d_ptr->f.DeleteFramebuffers(n, framebuffers);
  1229. #endif
  1230. Q_OPENGL_FUNCTIONS_DEBUG
  1231. }
  1232. inline void QOpenGLFunctions::glDeleteProgram(GLuint program)
  1233. {
  1234. #ifdef QT_OPENGL_ES_2
  1235. ::glDeleteProgram(program);
  1236. #else
  1237. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1238. d_ptr->f.DeleteProgram(program);
  1239. #endif
  1240. Q_OPENGL_FUNCTIONS_DEBUG
  1241. }
  1242. inline void QOpenGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
  1243. {
  1244. #ifdef QT_OPENGL_ES_2
  1245. ::glDeleteRenderbuffers(n, renderbuffers);
  1246. #else
  1247. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1248. d_ptr->f.DeleteRenderbuffers(n, renderbuffers);
  1249. #endif
  1250. Q_OPENGL_FUNCTIONS_DEBUG
  1251. }
  1252. inline void QOpenGLFunctions::glDeleteShader(GLuint shader)
  1253. {
  1254. #ifdef QT_OPENGL_ES_2
  1255. ::glDeleteShader(shader);
  1256. #else
  1257. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1258. d_ptr->f.DeleteShader(shader);
  1259. #endif
  1260. Q_OPENGL_FUNCTIONS_DEBUG
  1261. }
  1262. inline void QOpenGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar)
  1263. {
  1264. #ifndef QT_OPENGL_ES
  1265. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1266. d_ptr->f.DepthRangef(zNear, zFar);
  1267. #else
  1268. ::glDepthRangef(zNear, zFar);
  1269. #endif
  1270. Q_OPENGL_FUNCTIONS_DEBUG
  1271. }
  1272. inline void QOpenGLFunctions::glDetachShader(GLuint program, GLuint shader)
  1273. {
  1274. #ifdef QT_OPENGL_ES_2
  1275. ::glDetachShader(program, shader);
  1276. #else
  1277. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1278. d_ptr->f.DetachShader(program, shader);
  1279. #endif
  1280. Q_OPENGL_FUNCTIONS_DEBUG
  1281. }
  1282. inline void QOpenGLFunctions::glDisableVertexAttribArray(GLuint index)
  1283. {
  1284. #ifdef QT_OPENGL_ES_2
  1285. ::glDisableVertexAttribArray(index);
  1286. #else
  1287. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1288. d_ptr->f.DisableVertexAttribArray(index);
  1289. #endif
  1290. Q_OPENGL_FUNCTIONS_DEBUG
  1291. }
  1292. inline void QOpenGLFunctions::glEnableVertexAttribArray(GLuint index)
  1293. {
  1294. #ifdef QT_OPENGL_ES_2
  1295. ::glEnableVertexAttribArray(index);
  1296. #else
  1297. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1298. d_ptr->f.EnableVertexAttribArray(index);
  1299. #endif
  1300. Q_OPENGL_FUNCTIONS_DEBUG
  1301. }
  1302. inline void QOpenGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
  1303. {
  1304. #ifdef QT_OPENGL_ES_2
  1305. ::glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
  1306. #else
  1307. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1308. d_ptr->f.FramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
  1309. #endif
  1310. Q_OPENGL_FUNCTIONS_DEBUG
  1311. }
  1312. inline void QOpenGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
  1313. {
  1314. #ifdef QT_OPENGL_ES_2
  1315. ::glFramebufferTexture2D(target, attachment, textarget, texture, level);
  1316. #else
  1317. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1318. d_ptr->f.FramebufferTexture2D(target, attachment, textarget, texture, level);
  1319. #endif
  1320. Q_OPENGL_FUNCTIONS_DEBUG
  1321. }
  1322. inline void QOpenGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers)
  1323. {
  1324. #ifdef QT_OPENGL_ES_2
  1325. ::glGenBuffers(n, buffers);
  1326. #else
  1327. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1328. d_ptr->f.GenBuffers(n, buffers);
  1329. #endif
  1330. Q_OPENGL_FUNCTIONS_DEBUG
  1331. }
  1332. inline void QOpenGLFunctions::glGenerateMipmap(GLenum target)
  1333. {
  1334. #ifdef QT_OPENGL_ES_2
  1335. ::glGenerateMipmap(target);
  1336. #else
  1337. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1338. d_ptr->f.GenerateMipmap(target);
  1339. #endif
  1340. Q_OPENGL_FUNCTIONS_DEBUG
  1341. }
  1342. inline void QOpenGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers)
  1343. {
  1344. #ifdef QT_OPENGL_ES_2
  1345. ::glGenFramebuffers(n, framebuffers);
  1346. #else
  1347. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1348. d_ptr->f.GenFramebuffers(n, framebuffers);
  1349. #endif
  1350. Q_OPENGL_FUNCTIONS_DEBUG
  1351. }
  1352. inline void QOpenGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
  1353. {
  1354. #ifdef QT_OPENGL_ES_2
  1355. ::glGenRenderbuffers(n, renderbuffers);
  1356. #else
  1357. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1358. d_ptr->f.GenRenderbuffers(n, renderbuffers);
  1359. #endif
  1360. Q_OPENGL_FUNCTIONS_DEBUG
  1361. }
  1362. inline void QOpenGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
  1363. {
  1364. #ifdef QT_OPENGL_ES_2
  1365. ::glGetActiveAttrib(program, index, bufsize, length, size, type, name);
  1366. #else
  1367. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1368. d_ptr->f.GetActiveAttrib(program, index, bufsize, length, size, type, name);
  1369. #endif
  1370. Q_OPENGL_FUNCTIONS_DEBUG
  1371. }
  1372. inline void QOpenGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
  1373. {
  1374. #ifdef QT_OPENGL_ES_2
  1375. ::glGetActiveUniform(program, index, bufsize, length, size, type, name);
  1376. #else
  1377. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1378. d_ptr->f.GetActiveUniform(program, index, bufsize, length, size, type, name);
  1379. #endif
  1380. Q_OPENGL_FUNCTIONS_DEBUG
  1381. }
  1382. inline void QOpenGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
  1383. {
  1384. #ifdef QT_OPENGL_ES_2
  1385. ::glGetAttachedShaders(program, maxcount, count, shaders);
  1386. #else
  1387. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1388. d_ptr->f.GetAttachedShaders(program, maxcount, count, shaders);
  1389. #endif
  1390. Q_OPENGL_FUNCTIONS_DEBUG
  1391. }
  1392. inline GLint QOpenGLFunctions::glGetAttribLocation(GLuint program, const char* name)
  1393. {
  1394. #ifdef QT_OPENGL_ES_2
  1395. GLint result = ::glGetAttribLocation(program, name);
  1396. #else
  1397. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1398. GLint result = d_ptr->f.GetAttribLocation(program, name);
  1399. #endif
  1400. Q_OPENGL_FUNCTIONS_DEBUG
  1401. return result;
  1402. }
  1403. inline void QOpenGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
  1404. {
  1405. #ifdef QT_OPENGL_ES_2
  1406. ::glGetBufferParameteriv(target, pname, params);
  1407. #else
  1408. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1409. d_ptr->f.GetBufferParameteriv(target, pname, params);
  1410. #endif
  1411. Q_OPENGL_FUNCTIONS_DEBUG
  1412. }
  1413. inline void QOpenGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
  1414. {
  1415. #ifdef QT_OPENGL_ES_2
  1416. ::glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
  1417. #else
  1418. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1419. d_ptr->f.GetFramebufferAttachmentParameteriv(target, attachment, pname, params);
  1420. #endif
  1421. Q_OPENGL_FUNCTIONS_DEBUG
  1422. }
  1423. inline void QOpenGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params)
  1424. {
  1425. #ifdef QT_OPENGL_ES_2
  1426. ::glGetProgramiv(program, pname, params);
  1427. #else
  1428. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1429. d_ptr->f.GetProgramiv(program, pname, params);
  1430. #endif
  1431. Q_OPENGL_FUNCTIONS_DEBUG
  1432. }
  1433. inline void QOpenGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
  1434. {
  1435. #ifdef QT_OPENGL_ES_2
  1436. ::glGetProgramInfoLog(program, bufsize, length, infolog);
  1437. #else
  1438. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1439. d_ptr->f.GetProgramInfoLog(program, bufsize, length, infolog);
  1440. #endif
  1441. Q_OPENGL_FUNCTIONS_DEBUG
  1442. }
  1443. inline void QOpenGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
  1444. {
  1445. #ifdef QT_OPENGL_ES_2
  1446. ::glGetRenderbufferParameteriv(target, pname, params);
  1447. #else
  1448. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1449. d_ptr->f.GetRenderbufferParameteriv(target, pname, params);
  1450. #endif
  1451. Q_OPENGL_FUNCTIONS_DEBUG
  1452. }
  1453. inline void QOpenGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
  1454. {
  1455. #ifdef QT_OPENGL_ES_2
  1456. ::glGetShaderiv(shader, pname, params);
  1457. #else
  1458. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1459. d_ptr->f.GetShaderiv(shader, pname, params);
  1460. #endif
  1461. Q_OPENGL_FUNCTIONS_DEBUG
  1462. }
  1463. inline void QOpenGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
  1464. {
  1465. #ifdef QT_OPENGL_ES_2
  1466. ::glGetShaderInfoLog(shader, bufsize, length, infolog);
  1467. #else
  1468. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1469. d_ptr->f.GetShaderInfoLog(shader, bufsize, length, infolog);
  1470. #endif
  1471. Q_OPENGL_FUNCTIONS_DEBUG
  1472. }
  1473. inline void QOpenGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
  1474. {
  1475. #ifdef QT_OPENGL_ES_2
  1476. ::glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
  1477. #else
  1478. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1479. d_ptr->f.GetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
  1480. #endif
  1481. Q_OPENGL_FUNCTIONS_DEBUG
  1482. }
  1483. inline void QOpenGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
  1484. {
  1485. #ifdef QT_OPENGL_ES_2
  1486. ::glGetShaderSource(shader, bufsize, length, source);
  1487. #else
  1488. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1489. d_ptr->f.GetShaderSource(shader, bufsize, length, source);
  1490. #endif
  1491. Q_OPENGL_FUNCTIONS_DEBUG
  1492. }
  1493. inline void QOpenGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params)
  1494. {
  1495. #ifdef QT_OPENGL_ES_2
  1496. ::glGetUniformfv(program, location, params);
  1497. #else
  1498. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1499. d_ptr->f.GetUniformfv(program, location, params);
  1500. #endif
  1501. Q_OPENGL_FUNCTIONS_DEBUG
  1502. }
  1503. inline void QOpenGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params)
  1504. {
  1505. #ifdef QT_OPENGL_ES_2
  1506. ::glGetUniformiv(program, location, params);
  1507. #else
  1508. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1509. d_ptr->f.GetUniformiv(program, location, params);
  1510. #endif
  1511. Q_OPENGL_FUNCTIONS_DEBUG
  1512. }
  1513. inline GLint QOpenGLFunctions::glGetUniformLocation(GLuint program, const char* name)
  1514. {
  1515. #ifdef QT_OPENGL_ES_2
  1516. GLint result = ::glGetUniformLocation(program, name);
  1517. #else
  1518. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1519. GLint result = d_ptr->f.GetUniformLocation(program, name);
  1520. #endif
  1521. Q_OPENGL_FUNCTIONS_DEBUG
  1522. return result;
  1523. }
  1524. inline void QOpenGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
  1525. {
  1526. #ifdef QT_OPENGL_ES_2
  1527. ::glGetVertexAttribfv(index, pname, params);
  1528. #else
  1529. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1530. d_ptr->f.GetVertexAttribfv(index, pname, params);
  1531. #endif
  1532. Q_OPENGL_FUNCTIONS_DEBUG
  1533. }
  1534. inline void QOpenGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
  1535. {
  1536. #ifdef QT_OPENGL_ES_2
  1537. ::glGetVertexAttribiv(index, pname, params);
  1538. #else
  1539. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1540. d_ptr->f.GetVertexAttribiv(index, pname, params);
  1541. #endif
  1542. Q_OPENGL_FUNCTIONS_DEBUG
  1543. }
  1544. inline void QOpenGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
  1545. {
  1546. #ifdef QT_OPENGL_ES_2
  1547. ::glGetVertexAttribPointerv(index, pname, pointer);
  1548. #else
  1549. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1550. d_ptr->f.GetVertexAttribPointerv(index, pname, pointer);
  1551. #endif
  1552. Q_OPENGL_FUNCTIONS_DEBUG
  1553. }
  1554. inline GLboolean QOpenGLFunctions::glIsBuffer(GLuint buffer)
  1555. {
  1556. #ifdef QT_OPENGL_ES_2
  1557. GLboolean result = ::glIsBuffer(buffer);
  1558. #else
  1559. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1560. GLboolean result = d_ptr->f.IsBuffer(buffer);
  1561. #endif
  1562. Q_OPENGL_FUNCTIONS_DEBUG
  1563. return result;
  1564. }
  1565. inline GLboolean QOpenGLFunctions::glIsFramebuffer(GLuint framebuffer)
  1566. {
  1567. #ifdef QT_OPENGL_ES_2
  1568. GLboolean result = ::glIsFramebuffer(framebuffer);
  1569. #else
  1570. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1571. GLboolean result = d_ptr->f.IsFramebuffer(framebuffer);
  1572. #endif
  1573. Q_OPENGL_FUNCTIONS_DEBUG
  1574. return result;
  1575. }
  1576. inline GLboolean QOpenGLFunctions::glIsProgram(GLuint program)
  1577. {
  1578. #ifdef QT_OPENGL_ES_2
  1579. GLboolean result = ::glIsProgram(program);
  1580. #else
  1581. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1582. GLboolean result = d_ptr->f.IsProgram(program);
  1583. #endif
  1584. Q_OPENGL_FUNCTIONS_DEBUG
  1585. return result;
  1586. }
  1587. inline GLboolean QOpenGLFunctions::glIsRenderbuffer(GLuint renderbuffer)
  1588. {
  1589. #ifdef QT_OPENGL_ES_2
  1590. GLboolean result = ::glIsRenderbuffer(renderbuffer);
  1591. #else
  1592. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1593. GLboolean result = d_ptr->f.IsRenderbuffer(renderbuffer);
  1594. #endif
  1595. Q_OPENGL_FUNCTIONS_DEBUG
  1596. return result;
  1597. }
  1598. inline GLboolean QOpenGLFunctions::glIsShader(GLuint shader)
  1599. {
  1600. #ifdef QT_OPENGL_ES_2
  1601. GLboolean result = ::glIsShader(shader);
  1602. #else
  1603. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1604. GLboolean result = d_ptr->f.IsShader(shader);
  1605. #endif
  1606. Q_OPENGL_FUNCTIONS_DEBUG
  1607. return result;
  1608. }
  1609. inline void QOpenGLFunctions::glLinkProgram(GLuint program)
  1610. {
  1611. #ifdef QT_OPENGL_ES_2
  1612. ::glLinkProgram(program);
  1613. #else
  1614. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1615. d_ptr->f.LinkProgram(program);
  1616. #endif
  1617. Q_OPENGL_FUNCTIONS_DEBUG
  1618. }
  1619. inline void QOpenGLFunctions::glReleaseShaderCompiler()
  1620. {
  1621. #ifdef QT_OPENGL_ES_2
  1622. ::glReleaseShaderCompiler();
  1623. #else
  1624. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1625. d_ptr->f.ReleaseShaderCompiler();
  1626. #endif
  1627. Q_OPENGL_FUNCTIONS_DEBUG
  1628. }
  1629. inline void QOpenGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
  1630. {
  1631. #ifdef QT_OPENGL_ES_2
  1632. ::glRenderbufferStorage(target, internalformat, width, height);
  1633. #else
  1634. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1635. d_ptr->f.RenderbufferStorage(target, internalformat, width, height);
  1636. #endif
  1637. Q_OPENGL_FUNCTIONS_DEBUG
  1638. }
  1639. inline void QOpenGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert)
  1640. {
  1641. #ifdef QT_OPENGL_ES_2
  1642. ::glSampleCoverage(value, invert);
  1643. #else
  1644. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1645. d_ptr->f.SampleCoverage(value, invert);
  1646. #endif
  1647. Q_OPENGL_FUNCTIONS_DEBUG
  1648. }
  1649. inline void QOpenGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
  1650. {
  1651. #ifdef QT_OPENGL_ES_2
  1652. ::glShaderBinary(n, shaders, binaryformat, binary, length);
  1653. #else
  1654. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1655. d_ptr->f.ShaderBinary(n, shaders, binaryformat, binary, length);
  1656. #endif
  1657. Q_OPENGL_FUNCTIONS_DEBUG
  1658. }
  1659. inline void QOpenGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
  1660. {
  1661. #ifdef QT_OPENGL_ES_2
  1662. ::glShaderSource(shader, count, string, length);
  1663. #else
  1664. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1665. d_ptr->f.ShaderSource(shader, count, string, length);
  1666. #endif
  1667. Q_OPENGL_FUNCTIONS_DEBUG
  1668. }
  1669. inline void QOpenGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
  1670. {
  1671. #ifdef QT_OPENGL_ES_2
  1672. ::glStencilFuncSeparate(face, func, ref, mask);
  1673. #else
  1674. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1675. d_ptr->f.StencilFuncSeparate(face, func, ref, mask);
  1676. #endif
  1677. Q_OPENGL_FUNCTIONS_DEBUG
  1678. }
  1679. inline void QOpenGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask)
  1680. {
  1681. #ifdef QT_OPENGL_ES_2
  1682. ::glStencilMaskSeparate(face, mask);
  1683. #else
  1684. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1685. d_ptr->f.StencilMaskSeparate(face, mask);
  1686. #endif
  1687. Q_OPENGL_FUNCTIONS_DEBUG
  1688. }
  1689. inline void QOpenGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
  1690. {
  1691. #ifdef QT_OPENGL_ES_2
  1692. ::glStencilOpSeparate(face, fail, zfail, zpass);
  1693. #else
  1694. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1695. d_ptr->f.StencilOpSeparate(face, fail, zfail, zpass);
  1696. #endif
  1697. Q_OPENGL_FUNCTIONS_DEBUG
  1698. }
  1699. inline void QOpenGLFunctions::glUniform1f(GLint location, GLfloat x)
  1700. {
  1701. #ifdef QT_OPENGL_ES_2
  1702. ::glUniform1f(location, x);
  1703. #else
  1704. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1705. d_ptr->f.Uniform1f(location, x);
  1706. #endif
  1707. Q_OPENGL_FUNCTIONS_DEBUG
  1708. }
  1709. inline void QOpenGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
  1710. {
  1711. #ifdef QT_OPENGL_ES_2
  1712. ::glUniform1fv(location, count, v);
  1713. #else
  1714. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1715. d_ptr->f.Uniform1fv(location, count, v);
  1716. #endif
  1717. Q_OPENGL_FUNCTIONS_DEBUG
  1718. }
  1719. inline void QOpenGLFunctions::glUniform1i(GLint location, GLint x)
  1720. {
  1721. #ifdef QT_OPENGL_ES_2
  1722. ::glUniform1i(location, x);
  1723. #else
  1724. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1725. d_ptr->f.Uniform1i(location, x);
  1726. #endif
  1727. Q_OPENGL_FUNCTIONS_DEBUG
  1728. }
  1729. inline void QOpenGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v)
  1730. {
  1731. #ifdef QT_OPENGL_ES_2
  1732. ::glUniform1iv(location, count, v);
  1733. #else
  1734. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1735. d_ptr->f.Uniform1iv(location, count, v);
  1736. #endif
  1737. Q_OPENGL_FUNCTIONS_DEBUG
  1738. }
  1739. inline void QOpenGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y)
  1740. {
  1741. #ifdef QT_OPENGL_ES_2
  1742. ::glUniform2f(location, x, y);
  1743. #else
  1744. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1745. d_ptr->f.Uniform2f(location, x, y);
  1746. #endif
  1747. Q_OPENGL_FUNCTIONS_DEBUG
  1748. }
  1749. inline void QOpenGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
  1750. {
  1751. #ifdef QT_OPENGL_ES_2
  1752. ::glUniform2fv(location, count, v);
  1753. #else
  1754. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1755. d_ptr->f.Uniform2fv(location, count, v);
  1756. #endif
  1757. Q_OPENGL_FUNCTIONS_DEBUG
  1758. }
  1759. inline void QOpenGLFunctions::glUniform2i(GLint location, GLint x, GLint y)
  1760. {
  1761. #ifdef QT_OPENGL_ES_2
  1762. ::glUniform2i(location, x, y);
  1763. #else
  1764. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1765. d_ptr->f.Uniform2i(location, x, y);
  1766. #endif
  1767. Q_OPENGL_FUNCTIONS_DEBUG
  1768. }
  1769. inline void QOpenGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v)
  1770. {
  1771. #ifdef QT_OPENGL_ES_2
  1772. ::glUniform2iv(location, count, v);
  1773. #else
  1774. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1775. d_ptr->f.Uniform2iv(location, count, v);
  1776. #endif
  1777. Q_OPENGL_FUNCTIONS_DEBUG
  1778. }
  1779. inline void QOpenGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
  1780. {
  1781. #ifdef QT_OPENGL_ES_2
  1782. ::glUniform3f(location, x, y, z);
  1783. #else
  1784. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1785. d_ptr->f.Uniform3f(location, x, y, z);
  1786. #endif
  1787. Q_OPENGL_FUNCTIONS_DEBUG
  1788. }
  1789. inline void QOpenGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
  1790. {
  1791. #ifdef QT_OPENGL_ES_2
  1792. ::glUniform3fv(location, count, v);
  1793. #else
  1794. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1795. d_ptr->f.Uniform3fv(location, count, v);
  1796. #endif
  1797. Q_OPENGL_FUNCTIONS_DEBUG
  1798. }
  1799. inline void QOpenGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z)
  1800. {
  1801. #ifdef QT_OPENGL_ES_2
  1802. ::glUniform3i(location, x, y, z);
  1803. #else
  1804. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1805. d_ptr->f.Uniform3i(location, x, y, z);
  1806. #endif
  1807. Q_OPENGL_FUNCTIONS_DEBUG
  1808. }
  1809. inline void QOpenGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v)
  1810. {
  1811. #ifdef QT_OPENGL_ES_2
  1812. ::glUniform3iv(location, count, v);
  1813. #else
  1814. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1815. d_ptr->f.Uniform3iv(location, count, v);
  1816. #endif
  1817. Q_OPENGL_FUNCTIONS_DEBUG
  1818. }
  1819. inline void QOpenGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
  1820. {
  1821. #ifdef QT_OPENGL_ES_2
  1822. ::glUniform4f(location, x, y, z, w);
  1823. #else
  1824. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1825. d_ptr->f.Uniform4f(location, x, y, z, w);
  1826. #endif
  1827. Q_OPENGL_FUNCTIONS_DEBUG
  1828. }
  1829. inline void QOpenGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
  1830. {
  1831. #ifdef QT_OPENGL_ES_2
  1832. ::glUniform4fv(location, count, v);
  1833. #else
  1834. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1835. d_ptr->f.Uniform4fv(location, count, v);
  1836. #endif
  1837. Q_OPENGL_FUNCTIONS_DEBUG
  1838. }
  1839. inline void QOpenGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
  1840. {
  1841. #ifdef QT_OPENGL_ES_2
  1842. ::glUniform4i(location, x, y, z, w);
  1843. #else
  1844. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1845. d_ptr->f.Uniform4i(location, x, y, z, w);
  1846. #endif
  1847. Q_OPENGL_FUNCTIONS_DEBUG
  1848. }
  1849. inline void QOpenGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v)
  1850. {
  1851. #ifdef QT_OPENGL_ES_2
  1852. ::glUniform4iv(location, count, v);
  1853. #else
  1854. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1855. d_ptr->f.Uniform4iv(location, count, v);
  1856. #endif
  1857. Q_OPENGL_FUNCTIONS_DEBUG
  1858. }
  1859. inline void QOpenGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
  1860. {
  1861. #ifdef QT_OPENGL_ES_2
  1862. ::glUniformMatrix2fv(location, count, transpose, value);
  1863. #else
  1864. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1865. d_ptr->f.UniformMatrix2fv(location, count, transpose, value);
  1866. #endif
  1867. Q_OPENGL_FUNCTIONS_DEBUG
  1868. }
  1869. inline void QOpenGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
  1870. {
  1871. #ifdef QT_OPENGL_ES_2
  1872. ::glUniformMatrix3fv(location, count, transpose, value);
  1873. #else
  1874. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1875. d_ptr->f.UniformMatrix3fv(location, count, transpose, value);
  1876. #endif
  1877. Q_OPENGL_FUNCTIONS_DEBUG
  1878. }
  1879. inline void QOpenGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
  1880. {
  1881. #ifdef QT_OPENGL_ES_2
  1882. ::glUniformMatrix4fv(location, count, transpose, value);
  1883. #else
  1884. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1885. d_ptr->f.UniformMatrix4fv(location, count, transpose, value);
  1886. #endif
  1887. Q_OPENGL_FUNCTIONS_DEBUG
  1888. }
  1889. inline void QOpenGLFunctions::glUseProgram(GLuint program)
  1890. {
  1891. #ifdef QT_OPENGL_ES_2
  1892. ::glUseProgram(program);
  1893. #else
  1894. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1895. d_ptr->f.UseProgram(program);
  1896. #endif
  1897. Q_OPENGL_FUNCTIONS_DEBUG
  1898. }
  1899. inline void QOpenGLFunctions::glValidateProgram(GLuint program)
  1900. {
  1901. #ifdef QT_OPENGL_ES_2
  1902. ::glValidateProgram(program);
  1903. #else
  1904. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1905. d_ptr->f.ValidateProgram(program);
  1906. #endif
  1907. Q_OPENGL_FUNCTIONS_DEBUG
  1908. }
  1909. inline void QOpenGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x)
  1910. {
  1911. #ifdef QT_OPENGL_ES_2
  1912. ::glVertexAttrib1f(indx, x);
  1913. #else
  1914. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1915. d_ptr->f.VertexAttrib1f(indx, x);
  1916. #endif
  1917. Q_OPENGL_FUNCTIONS_DEBUG
  1918. }
  1919. inline void QOpenGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values)
  1920. {
  1921. #ifdef QT_OPENGL_ES_2
  1922. ::glVertexAttrib1fv(indx, values);
  1923. #else
  1924. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1925. d_ptr->f.VertexAttrib1fv(indx, values);
  1926. #endif
  1927. Q_OPENGL_FUNCTIONS_DEBUG
  1928. }
  1929. inline void QOpenGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
  1930. {
  1931. #ifdef QT_OPENGL_ES_2
  1932. ::glVertexAttrib2f(indx, x, y);
  1933. #else
  1934. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1935. d_ptr->f.VertexAttrib2f(indx, x, y);
  1936. #endif
  1937. Q_OPENGL_FUNCTIONS_DEBUG
  1938. }
  1939. inline void QOpenGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values)
  1940. {
  1941. #ifdef QT_OPENGL_ES_2
  1942. ::glVertexAttrib2fv(indx, values);
  1943. #else
  1944. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1945. d_ptr->f.VertexAttrib2fv(indx, values);
  1946. #endif
  1947. Q_OPENGL_FUNCTIONS_DEBUG
  1948. }
  1949. inline void QOpenGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
  1950. {
  1951. #ifdef QT_OPENGL_ES_2
  1952. ::glVertexAttrib3f(indx, x, y, z);
  1953. #else
  1954. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1955. d_ptr->f.VertexAttrib3f(indx, x, y, z);
  1956. #endif
  1957. Q_OPENGL_FUNCTIONS_DEBUG
  1958. }
  1959. inline void QOpenGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values)
  1960. {
  1961. #ifdef QT_OPENGL_ES_2
  1962. ::glVertexAttrib3fv(indx, values);
  1963. #else
  1964. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1965. d_ptr->f.VertexAttrib3fv(indx, values);
  1966. #endif
  1967. Q_OPENGL_FUNCTIONS_DEBUG
  1968. }
  1969. inline void QOpenGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
  1970. {
  1971. #ifdef QT_OPENGL_ES_2
  1972. ::glVertexAttrib4f(indx, x, y, z, w);
  1973. #else
  1974. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1975. d_ptr->f.VertexAttrib4f(indx, x, y, z, w);
  1976. #endif
  1977. Q_OPENGL_FUNCTIONS_DEBUG
  1978. }
  1979. inline void QOpenGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values)
  1980. {
  1981. #ifdef QT_OPENGL_ES_2
  1982. ::glVertexAttrib4fv(indx, values);
  1983. #else
  1984. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1985. d_ptr->f.VertexAttrib4fv(indx, values);
  1986. #endif
  1987. Q_OPENGL_FUNCTIONS_DEBUG
  1988. }
  1989. inline void QOpenGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
  1990. {
  1991. #ifdef QT_OPENGL_ES_2
  1992. ::glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
  1993. #else
  1994. Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
  1995. d_ptr->f.VertexAttribPointer(indx, size, type, normalized, stride, ptr);
  1996. #endif
  1997. Q_OPENGL_FUNCTIONS_DEBUG
  1998. }
  1999. #undef QT_OPENGL_DECLARE_FUNCTIONS
  2000. #undef QT_OPENGL_COUNT_FUNCTIONS
  2001. #undef QT_OPENGL_DECLARE
  2002. QT_END_NAMESPACE
  2003. #endif // QT_NO_OPENGL
  2004. #endif