PageRenderTime 128ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/OpenSceneGraph/src/osg/GL2Extensions.cpp

https://bitbucket.org/jgrocha/osgearthandroid
C++ | 2932 lines | 2412 code | 451 blank | 69 comment | 347 complexity | 0316ef187a5d33ca6a17ccad89c80bc2 MD5 | raw file
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. * Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
  3. * Copyright (C) 2004-2005 Nathan Cournia
  4. * Copyright (C) 2008 Zebra Imaging
  5. * Copyright (C) 2012 David Callu
  6. *
  7. * This application is open source and may be redistributed and/or modified
  8. * freely and without restriction, both in commercial and non commercial
  9. * applications, as long as this copyright notice is maintained.
  10. *
  11. * This application is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. */
  16. /* file: src/osg/GL2Extensions.cpp
  17. * author: Mike Weiblen 2008-01-19
  18. */
  19. #include <osg/Notify>
  20. #include <osg/buffered_value>
  21. #include <osg/ref_ptr>
  22. #include <osg/GL2Extensions>
  23. #include <osg/GLExtensions>
  24. #include <osg/Math>
  25. using namespace osg;
  26. ///////////////////////////////////////////////////////////////////////////
  27. // Extension function pointers for OpenGL v2.x
  28. GL2Extensions::GL2Extensions(unsigned int contextID)
  29. {
  30. setupGL2Extensions(contextID);
  31. }
  32. GL2Extensions::GL2Extensions(const GL2Extensions& rhs) : osg::Referenced()
  33. {
  34. _glVersion = rhs._glVersion;
  35. _glslLanguageVersion = rhs._glslLanguageVersion;
  36. _isShaderObjectsSupported = rhs._isShaderObjectsSupported;
  37. _isVertexShaderSupported = rhs._isVertexShaderSupported;
  38. _isFragmentShaderSupported = rhs._isFragmentShaderSupported;
  39. _isLanguage100Supported = rhs._isLanguage100Supported;
  40. _isGeometryShader4Supported = rhs._isGeometryShader4Supported;
  41. _areTessellationShadersSupported = rhs._areTessellationShadersSupported;
  42. _isGpuShader4Supported = rhs._isGpuShader4Supported;
  43. _isUniformBufferObjectSupported = rhs._isUniformBufferObjectSupported;
  44. _isGetProgramBinarySupported = rhs._isGetProgramBinarySupported;
  45. _isGpuShaderFp64Supported = rhs._isGpuShaderFp64Supported;
  46. _isShaderAtomicCountersSupported = rhs._isShaderAtomicCountersSupported;
  47. _glBlendEquationSeparate = rhs._glBlendEquationSeparate;
  48. _glDrawBuffers = rhs._glDrawBuffers;
  49. _glStencilOpSeparate = rhs._glStencilOpSeparate;
  50. _glStencilFuncSeparate = rhs._glStencilFuncSeparate;
  51. _glStencilMaskSeparate = rhs._glStencilMaskSeparate;
  52. _glAttachShader = rhs._glAttachShader;
  53. _glBindAttribLocation = rhs._glBindAttribLocation;
  54. _glCompileShader = rhs._glCompileShader;
  55. _glCreateProgram = rhs._glCreateProgram;
  56. _glCreateShader = rhs._glCreateShader;
  57. _glDeleteProgram = rhs._glDeleteProgram;
  58. _glDeleteShader = rhs._glDeleteShader;
  59. _glDetachShader = rhs._glDetachShader;
  60. _glDisableVertexAttribArray = rhs._glDisableVertexAttribArray;
  61. _glEnableVertexAttribArray = rhs._glEnableVertexAttribArray;
  62. _glGetActiveAttrib = rhs._glGetActiveAttrib;
  63. _glGetActiveUniform = rhs._glGetActiveUniform;
  64. _glGetAttachedShaders = rhs._glGetAttachedShaders;
  65. _glGetAttribLocation = rhs._glGetAttribLocation;
  66. _glGetProgramiv = rhs._glGetProgramiv;
  67. _glGetProgramInfoLog = rhs._glGetProgramInfoLog;
  68. _glGetShaderiv = rhs._glGetShaderiv;
  69. _glGetShaderInfoLog = rhs._glGetShaderInfoLog;
  70. _glGetShaderSource = rhs._glGetShaderSource;
  71. _glGetUniformLocation = rhs._glGetUniformLocation;
  72. _glGetUniformfv = rhs._glGetUniformfv;
  73. _glGetUniformiv = rhs._glGetUniformiv;
  74. _glGetVertexAttribdv = rhs._glGetVertexAttribdv;
  75. _glGetVertexAttribfv = rhs._glGetVertexAttribfv;
  76. _glGetVertexAttribiv = rhs._glGetVertexAttribiv;
  77. _glGetVertexAttribPointerv = rhs._glGetVertexAttribPointerv;
  78. _glIsProgram = rhs._glIsProgram;
  79. _glIsShader = rhs._glIsShader;
  80. _glLinkProgram = rhs._glLinkProgram;
  81. _glShaderSource = rhs._glShaderSource;
  82. _glUseProgram = rhs._glUseProgram;
  83. _glUniform1f = rhs._glUniform1f;
  84. _glUniform2f = rhs._glUniform2f;
  85. _glUniform3f = rhs._glUniform3f;
  86. _glUniform4f = rhs._glUniform4f;
  87. _glUniform1i = rhs._glUniform1i;
  88. _glUniform2i = rhs._glUniform2i;
  89. _glUniform3i = rhs._glUniform3i;
  90. _glUniform4i = rhs._glUniform4i;
  91. _glUniform1fv = rhs._glUniform1fv;
  92. _glUniform2fv = rhs._glUniform2fv;
  93. _glUniform3fv = rhs._glUniform3fv;
  94. _glUniform4fv = rhs._glUniform4fv;
  95. _glUniform1iv = rhs._glUniform1iv;
  96. _glUniform2iv = rhs._glUniform2iv;
  97. _glUniform3iv = rhs._glUniform3iv;
  98. _glUniform4iv = rhs._glUniform4iv;
  99. _glUniformMatrix2fv = rhs._glUniformMatrix2fv;
  100. _glUniformMatrix3fv = rhs._glUniformMatrix3fv;
  101. _glUniformMatrix4fv = rhs._glUniformMatrix4fv;
  102. _glValidateProgram = rhs._glValidateProgram;
  103. _glVertexAttrib1d = rhs._glVertexAttrib1d;
  104. _glVertexAttrib1dv = rhs._glVertexAttrib1dv;
  105. _glVertexAttrib1f = rhs._glVertexAttrib1f;
  106. _glVertexAttrib1fv = rhs._glVertexAttrib1fv;
  107. _glVertexAttrib1s = rhs._glVertexAttrib1s;
  108. _glVertexAttrib1sv = rhs._glVertexAttrib1sv;
  109. _glVertexAttrib2d = rhs._glVertexAttrib2d;
  110. _glVertexAttrib2dv = rhs._glVertexAttrib2dv;
  111. _glVertexAttrib2f = rhs._glVertexAttrib2f;
  112. _glVertexAttrib2fv = rhs._glVertexAttrib2fv;
  113. _glVertexAttrib2s = rhs._glVertexAttrib2s;
  114. _glVertexAttrib2sv = rhs._glVertexAttrib2sv;
  115. _glVertexAttrib3d = rhs._glVertexAttrib3d;
  116. _glVertexAttrib3dv = rhs._glVertexAttrib3dv;
  117. _glVertexAttrib3f = rhs._glVertexAttrib3f;
  118. _glVertexAttrib3fv = rhs._glVertexAttrib3fv;
  119. _glVertexAttrib3s = rhs._glVertexAttrib3s;
  120. _glVertexAttrib3sv = rhs._glVertexAttrib3sv;
  121. _glVertexAttrib4Nbv = rhs._glVertexAttrib4Nbv;
  122. _glVertexAttrib4Niv = rhs._glVertexAttrib4Niv;
  123. _glVertexAttrib4Nsv = rhs._glVertexAttrib4Nsv;
  124. _glVertexAttrib4Nub = rhs._glVertexAttrib4Nub;
  125. _glVertexAttrib4Nubv = rhs._glVertexAttrib4Nubv;
  126. _glVertexAttrib4Nuiv = rhs._glVertexAttrib4Nuiv;
  127. _glVertexAttrib4Nusv = rhs._glVertexAttrib4Nusv;
  128. _glVertexAttrib4bv = rhs._glVertexAttrib4bv;
  129. _glVertexAttrib4d = rhs._glVertexAttrib4d;
  130. _glVertexAttrib4dv = rhs._glVertexAttrib4dv;
  131. _glVertexAttrib4f = rhs._glVertexAttrib4f;
  132. _glVertexAttrib4fv = rhs._glVertexAttrib4fv;
  133. _glVertexAttrib4iv = rhs._glVertexAttrib4iv;
  134. _glVertexAttrib4s = rhs._glVertexAttrib4s;
  135. _glVertexAttrib4sv = rhs._glVertexAttrib4sv;
  136. _glVertexAttrib4ubv = rhs._glVertexAttrib4ubv;
  137. _glVertexAttrib4uiv = rhs._glVertexAttrib4uiv;
  138. _glVertexAttrib4usv = rhs._glVertexAttrib4usv;
  139. _glVertexAttribPointer = rhs._glVertexAttribPointer;
  140. _glGetInfoLogARB = rhs._glGetInfoLogARB;
  141. _glGetObjectParameterivARB = rhs._glGetObjectParameterivARB;
  142. _glDeleteObjectARB = rhs._glDeleteObjectARB;
  143. _glGetHandleARB = rhs._glGetHandleARB;
  144. // GL 2.1
  145. _glUniformMatrix2x3fv = rhs._glUniformMatrix2x3fv;
  146. _glUniformMatrix3x2fv = rhs._glUniformMatrix3x2fv;
  147. _glUniformMatrix2x4fv = rhs._glUniformMatrix2x4fv;
  148. _glUniformMatrix4x2fv = rhs._glUniformMatrix4x2fv;
  149. _glUniformMatrix3x4fv = rhs._glUniformMatrix3x4fv;
  150. _glUniformMatrix4x3fv = rhs._glUniformMatrix4x3fv;
  151. // EXT_geometry_shader4
  152. _glProgramParameteri = rhs._glProgramParameteri;
  153. _glFramebufferTexture = rhs._glFramebufferTexture;
  154. _glFramebufferTextureLayer = rhs._glFramebufferTextureLayer;
  155. _glFramebufferTextureFace = rhs._glFramebufferTextureFace;
  156. // EXT_gpu_shader4
  157. _glGetUniformuiv = rhs._glGetUniformuiv;
  158. _glBindFragDataLocation = rhs._glBindFragDataLocation;
  159. _glGetFragDataLocation = rhs._glGetFragDataLocation;
  160. _glUniform1ui = rhs._glUniform1ui;
  161. _glUniform2ui = rhs._glUniform2ui;
  162. _glUniform3ui = rhs._glUniform3ui;
  163. _glUniform4ui = rhs._glUniform4ui;
  164. _glUniform1uiv = rhs._glUniform1uiv;
  165. _glUniform2uiv = rhs._glUniform2uiv;
  166. _glUniform3uiv = rhs._glUniform3uiv;
  167. _glUniform4uiv = rhs._glUniform4uiv;
  168. // ARB_uniform_buffer_object
  169. _glGetUniformIndices = rhs._glGetUniformIndices;
  170. _glGetActiveUniformsiv = rhs._glGetActiveUniformsiv;
  171. _glGetActiveUniformName = rhs._glGetActiveUniformName;
  172. _glGetUniformBlockIndex = rhs._glGetUniformBlockIndex;
  173. _glGetActiveUniformBlockiv = rhs._glGetActiveUniformBlockiv;
  174. _glGetActiveUniformBlockName = rhs._glGetActiveUniformBlockName;
  175. _glUniformBlockBinding = rhs._glUniformBlockBinding;
  176. // ARB_get_program_binary
  177. _glGetProgramBinary = rhs._glGetProgramBinary;
  178. _glProgramBinary = rhs._glProgramBinary;
  179. // ARB_gpu_shader_fp64
  180. _glUniform1d = rhs._glUniform1d;
  181. _glUniform2d = rhs._glUniform2d;
  182. _glUniform3d = rhs._glUniform3d;
  183. _glUniform4d = rhs._glUniform4d;
  184. _glUniform1dv = rhs._glUniform1dv;
  185. _glUniform2dv = rhs._glUniform2dv;
  186. _glUniform3dv = rhs._glUniform3dv;
  187. _glUniform4dv = rhs._glUniform4dv;
  188. _glUniformMatrix2dv = rhs._glUniformMatrix2dv;
  189. _glUniformMatrix3dv = rhs._glUniformMatrix3dv;
  190. _glUniformMatrix4dv = rhs._glUniformMatrix4dv;
  191. _glUniformMatrix2x3dv = rhs._glUniformMatrix2x3dv;
  192. _glUniformMatrix3x2dv = rhs._glUniformMatrix3x2dv;
  193. _glUniformMatrix2x4dv = rhs._glUniformMatrix2x4dv;
  194. _glUniformMatrix4x2dv = rhs._glUniformMatrix4x2dv;
  195. _glUniformMatrix3x4dv = rhs._glUniformMatrix3x4dv;
  196. _glUniformMatrix4x3dv = rhs._glUniformMatrix4x3dv;
  197. // ARB_shader_atomic_counters
  198. _glGetActiveAtomicCounterBufferiv = rhs._glGetActiveAtomicCounterBufferiv;
  199. }
  200. void GL2Extensions::lowestCommonDenominator(const GL2Extensions& rhs)
  201. {
  202. if (rhs._glVersion < _glVersion) _glVersion = rhs._glVersion;
  203. if (rhs._glslLanguageVersion < _glslLanguageVersion)
  204. _glslLanguageVersion = rhs._glslLanguageVersion;
  205. if (!rhs._isShaderObjectsSupported) _isShaderObjectsSupported = false;
  206. if (!rhs._isVertexShaderSupported) _isVertexShaderSupported = false;
  207. if (!rhs._isFragmentShaderSupported) _isFragmentShaderSupported = false;
  208. if (!rhs._isLanguage100Supported) _isLanguage100Supported = false;
  209. if (!rhs._isGeometryShader4Supported) _isGeometryShader4Supported = false;
  210. if (!rhs._areTessellationShadersSupported) _areTessellationShadersSupported = false;
  211. if (!rhs._isGpuShader4Supported) _isGpuShader4Supported = false;
  212. if (!rhs._isUniformBufferObjectSupported) _isUniformBufferObjectSupported = false;
  213. if (!rhs._isGetProgramBinarySupported) _isGetProgramBinarySupported = false;
  214. if (!rhs._isGpuShaderFp64Supported) _isGpuShaderFp64Supported = false;
  215. if (!rhs._isShaderAtomicCountersSupported) _isShaderAtomicCountersSupported = false;
  216. if (!rhs._glBlendEquationSeparate) _glBlendEquationSeparate = 0;
  217. if (!rhs._glDrawBuffers) _glDrawBuffers = 0;
  218. if (!rhs._glStencilOpSeparate) _glStencilOpSeparate = 0;
  219. if (!rhs._glStencilFuncSeparate) _glStencilFuncSeparate = 0;
  220. if (!rhs._glStencilMaskSeparate) _glStencilMaskSeparate = 0;
  221. if (!rhs._glAttachShader) _glAttachShader = 0;
  222. if (!rhs._glBindAttribLocation) _glBindAttribLocation = 0;
  223. if (!rhs._glCompileShader) _glCompileShader = 0;
  224. if (!rhs._glCreateProgram) _glCreateProgram = 0;
  225. if (!rhs._glCreateShader) _glCreateShader = 0;
  226. if (!rhs._glDeleteProgram) _glDeleteProgram = 0;
  227. if (!rhs._glDeleteShader) _glDeleteShader = 0;
  228. if (!rhs._glDetachShader) _glDetachShader = 0;
  229. if (!rhs._glDisableVertexAttribArray) _glDisableVertexAttribArray = 0;
  230. if (!rhs._glEnableVertexAttribArray) _glEnableVertexAttribArray = 0;
  231. if (!rhs._glGetActiveAttrib) _glGetActiveAttrib = 0;
  232. if (!rhs._glGetActiveUniform) _glGetActiveUniform = 0;
  233. if (!rhs._glGetAttachedShaders) _glGetAttachedShaders = 0;
  234. if (!rhs._glGetAttribLocation) _glGetAttribLocation = 0;
  235. if (!rhs._glGetProgramiv) _glGetProgramiv = 0;
  236. if (!rhs._glGetProgramInfoLog) _glGetProgramInfoLog = 0;
  237. if (!rhs._glGetShaderiv) _glGetShaderiv = 0;
  238. if (!rhs._glGetShaderInfoLog) _glGetShaderInfoLog = 0;
  239. if (!rhs._glGetShaderSource) _glGetShaderSource = 0;
  240. if (!rhs._glGetUniformLocation) _glGetUniformLocation = 0;
  241. if (!rhs._glGetUniformfv) _glGetUniformfv = 0;
  242. if (!rhs._glGetUniformiv) _glGetUniformiv = 0;
  243. if (!rhs._glGetVertexAttribdv) _glGetVertexAttribdv = 0;
  244. if (!rhs._glGetVertexAttribfv) _glGetVertexAttribfv = 0;
  245. if (!rhs._glGetVertexAttribiv) _glGetVertexAttribiv = 0;
  246. if (!rhs._glGetVertexAttribPointerv) _glGetVertexAttribPointerv = 0;
  247. if (!rhs._glIsProgram) _glIsProgram = 0;
  248. if (!rhs._glIsShader) _glIsShader = 0;
  249. if (!rhs._glLinkProgram) _glLinkProgram = 0;
  250. if (!rhs._glShaderSource) _glShaderSource = 0;
  251. if (!rhs._glUseProgram) _glUseProgram = 0;
  252. if (!rhs._glUniform1f) _glUniform1f = 0;
  253. if (!rhs._glUniform2f) _glUniform2f = 0;
  254. if (!rhs._glUniform3f) _glUniform3f = 0;
  255. if (!rhs._glUniform4f) _glUniform4f = 0;
  256. if (!rhs._glUniform1i) _glUniform1i = 0;
  257. if (!rhs._glUniform2i) _glUniform2i = 0;
  258. if (!rhs._glUniform3i) _glUniform3i = 0;
  259. if (!rhs._glUniform4i) _glUniform4i = 0;
  260. if (!rhs._glUniform1fv) _glUniform1fv = 0;
  261. if (!rhs._glUniform2fv) _glUniform2fv = 0;
  262. if (!rhs._glUniform3fv) _glUniform3fv = 0;
  263. if (!rhs._glUniform4fv) _glUniform4fv = 0;
  264. if (!rhs._glUniform1iv) _glUniform1iv = 0;
  265. if (!rhs._glUniform2iv) _glUniform2iv = 0;
  266. if (!rhs._glUniform3iv) _glUniform3iv = 0;
  267. if (!rhs._glUniform4iv) _glUniform4iv = 0;
  268. if (!rhs._glUniformMatrix2fv) _glUniformMatrix2fv = 0;
  269. if (!rhs._glUniformMatrix3fv) _glUniformMatrix3fv = 0;
  270. if (!rhs._glUniformMatrix4fv) _glUniformMatrix4fv = 0;
  271. if (!rhs._glValidateProgram) _glValidateProgram = 0;
  272. if (!rhs._glVertexAttrib1d) _glVertexAttrib1d = 0;
  273. if (!rhs._glVertexAttrib1dv) _glVertexAttrib1dv = 0;
  274. if (!rhs._glVertexAttrib1f) _glVertexAttrib1f = 0;
  275. if (!rhs._glVertexAttrib1fv) _glVertexAttrib1fv = 0;
  276. if (!rhs._glVertexAttrib1s) _glVertexAttrib1s = 0;
  277. if (!rhs._glVertexAttrib1sv) _glVertexAttrib1sv = 0;
  278. if (!rhs._glVertexAttrib2d) _glVertexAttrib2d = 0;
  279. if (!rhs._glVertexAttrib2dv) _glVertexAttrib2dv = 0;
  280. if (!rhs._glVertexAttrib2f) _glVertexAttrib2f = 0;
  281. if (!rhs._glVertexAttrib2fv) _glVertexAttrib2fv = 0;
  282. if (!rhs._glVertexAttrib2s) _glVertexAttrib2s = 0;
  283. if (!rhs._glVertexAttrib2sv) _glVertexAttrib2sv = 0;
  284. if (!rhs._glVertexAttrib3d) _glVertexAttrib3d = 0;
  285. if (!rhs._glVertexAttrib3dv) _glVertexAttrib3dv = 0;
  286. if (!rhs._glVertexAttrib3f) _glVertexAttrib3f = 0;
  287. if (!rhs._glVertexAttrib3fv) _glVertexAttrib3fv = 0;
  288. if (!rhs._glVertexAttrib3s) _glVertexAttrib3s = 0;
  289. if (!rhs._glVertexAttrib3sv) _glVertexAttrib3sv = 0;
  290. if (!rhs._glVertexAttrib4Nbv) _glVertexAttrib4Nbv = 0;
  291. if (!rhs._glVertexAttrib4Niv) _glVertexAttrib4Niv = 0;
  292. if (!rhs._glVertexAttrib4Nsv) _glVertexAttrib4Nsv = 0;
  293. if (!rhs._glVertexAttrib4Nub) _glVertexAttrib4Nub = 0;
  294. if (!rhs._glVertexAttrib4Nubv) _glVertexAttrib4Nubv = 0;
  295. if (!rhs._glVertexAttrib4Nuiv) _glVertexAttrib4Nuiv = 0;
  296. if (!rhs._glVertexAttrib4Nusv) _glVertexAttrib4Nusv = 0;
  297. if (!rhs._glVertexAttrib4bv) _glVertexAttrib4bv = 0;
  298. if (!rhs._glVertexAttrib4d) _glVertexAttrib4d = 0;
  299. if (!rhs._glVertexAttrib4dv) _glVertexAttrib4dv = 0;
  300. if (!rhs._glVertexAttrib4f) _glVertexAttrib4f = 0;
  301. if (!rhs._glVertexAttrib4fv) _glVertexAttrib4fv = 0;
  302. if (!rhs._glVertexAttrib4iv) _glVertexAttrib4iv = 0;
  303. if (!rhs._glVertexAttrib4s) _glVertexAttrib4s = 0;
  304. if (!rhs._glVertexAttrib4sv) _glVertexAttrib4sv = 0;
  305. if (!rhs._glVertexAttrib4ubv) _glVertexAttrib4ubv = 0;
  306. if (!rhs._glVertexAttrib4uiv) _glVertexAttrib4uiv = 0;
  307. if (!rhs._glVertexAttrib4usv) _glVertexAttrib4usv = 0;
  308. if (!rhs._glVertexAttribPointer) _glVertexAttribPointer = 0;
  309. if (!rhs._glGetInfoLogARB) _glGetInfoLogARB = 0;
  310. if (!rhs._glGetObjectParameterivARB) _glGetObjectParameterivARB = 0;
  311. if (!rhs._glDeleteObjectARB) _glDeleteObjectARB = 0;
  312. if (!rhs._glGetHandleARB) _glGetHandleARB = 0;
  313. // GL 2.1
  314. if (!rhs._glUniformMatrix2x3fv) _glUniformMatrix2x3fv = 0;
  315. if (!rhs._glUniformMatrix3x2fv) _glUniformMatrix3x2fv = 0;
  316. if (!rhs._glUniformMatrix2x4fv) _glUniformMatrix2x4fv = 0;
  317. if (!rhs._glUniformMatrix4x2fv) _glUniformMatrix4x2fv = 0;
  318. if (!rhs._glUniformMatrix3x4fv) _glUniformMatrix3x4fv = 0;
  319. if (!rhs._glUniformMatrix4x3fv) _glUniformMatrix4x3fv = 0;
  320. // EXT_geometry_shader4
  321. if (!rhs._glProgramParameteri) _glProgramParameteri = 0;
  322. if (!rhs._glFramebufferTexture) _glFramebufferTexture = 0;
  323. if (!rhs._glFramebufferTextureLayer) _glFramebufferTextureLayer = 0;
  324. if (!rhs._glFramebufferTextureFace) _glFramebufferTextureFace = 0;
  325. // ARB_tessellation_shader
  326. if (!rhs._glPatchParameteri) _glPatchParameteri = 0;
  327. if (!rhs._glPatchParameterfv) _glPatchParameterfv = 0;
  328. // EXT_gpu_shader4
  329. if (!rhs._glGetUniformuiv) _glGetUniformuiv = 0;
  330. if (!rhs._glBindFragDataLocation) _glBindFragDataLocation = 0;
  331. if (!rhs._glGetFragDataLocation) _glGetFragDataLocation = 0;
  332. if (!rhs._glUniform1ui) _glUniform1ui = 0;
  333. if (!rhs._glUniform2ui) _glUniform2ui = 0;
  334. if (!rhs._glUniform3ui) _glUniform3ui = 0;
  335. if (!rhs._glUniform4ui) _glUniform4ui = 0;
  336. if (!rhs._glUniform1uiv) _glUniform1uiv = 0;
  337. if (!rhs._glUniform2uiv) _glUniform2uiv = 0;
  338. if (!rhs._glUniform3uiv) _glUniform3uiv = 0;
  339. if (!rhs._glUniform4uiv) _glUniform4uiv = 0;
  340. // ARB_uniform_buffer_object
  341. if (!rhs._glGetUniformIndices) _glGetUniformIndices = 0;
  342. if (!rhs._glGetActiveUniformsiv) _glGetActiveUniformsiv = 0;
  343. if (!rhs._glGetActiveUniformName) _glGetActiveUniformName = 0;
  344. if (!rhs._glGetUniformBlockIndex) _glGetUniformBlockIndex = 0;
  345. if (!rhs._glGetActiveUniformBlockiv) _glGetActiveUniformBlockiv = 0;
  346. if (!rhs._glGetActiveUniformBlockName) _glGetActiveUniformBlockName = 0;
  347. if (!rhs._glUniformBlockBinding) _glUniformBlockBinding = 0;
  348. // ARB_get_program_binary
  349. if (!rhs._glGetProgramBinary) _glGetProgramBinary = 0;
  350. if (!rhs._glProgramBinary) _glProgramBinary = 0;
  351. // ARB_gpu_shader_fp64
  352. if(!rhs._glUniform1d) _glUniform1d = 0;
  353. if(!rhs._glUniform2d) _glUniform2d = 0;
  354. if(!rhs._glUniform3d) _glUniform3d = 0;
  355. if(!rhs._glUniform4d) _glUniform4d = 0;
  356. if(!rhs._glUniform1dv) _glUniform1dv = 0;
  357. if(!rhs._glUniform2dv) _glUniform2dv = 0;
  358. if(!rhs._glUniform3dv) _glUniform3dv = 0;
  359. if(!rhs._glUniform4dv) _glUniform4dv = 0;
  360. if(!rhs._glUniformMatrix2dv) _glUniformMatrix2dv = 0;
  361. if(!rhs._glUniformMatrix3dv) _glUniformMatrix3dv = 0;
  362. if(!rhs._glUniformMatrix4dv) _glUniformMatrix4dv = 0;
  363. if(!rhs._glUniformMatrix2x3dv) _glUniformMatrix2x3dv = 0;
  364. if(!rhs._glUniformMatrix3x2dv) _glUniformMatrix3x2dv = 0;
  365. if(!rhs._glUniformMatrix2x4dv) _glUniformMatrix2x4dv = 0;
  366. if(!rhs._glUniformMatrix4x2dv) _glUniformMatrix4x2dv = 0;
  367. if(!rhs._glUniformMatrix3x4dv) _glUniformMatrix3x4dv = 0;
  368. if(!rhs._glUniformMatrix4x3dv) _glUniformMatrix4x3dv = 0;
  369. // ARB_shader_atomic_counters
  370. if(!rhs._glGetActiveAtomicCounterBufferiv) _glGetActiveAtomicCounterBufferiv = 0;
  371. }
  372. void GL2Extensions::setupGL2Extensions(unsigned int contextID)
  373. {
  374. const char* version = (const char*) glGetString( GL_VERSION );
  375. if (!version)
  376. {
  377. OSG_NOTIFY(osg::FATAL)<<"Error: OpenGL version test failed, requires valid graphics context."<<std::endl;
  378. _glVersion = 0.0f;
  379. _glslLanguageVersion = 0.0f;
  380. _isShaderObjectsSupported = false;
  381. _isVertexShaderSupported = false;
  382. _isFragmentShaderSupported = false;
  383. _isLanguage100Supported = false;
  384. _isGeometryShader4Supported = false;
  385. _areTessellationShadersSupported = false;
  386. _isGpuShader4Supported = false;
  387. _isUniformBufferObjectSupported = false;
  388. _isGetProgramBinarySupported = false;
  389. _isGpuShaderFp64Supported = false;
  390. _isShaderAtomicCountersSupported = false;
  391. _glBlendEquationSeparate= 0;
  392. _glDrawBuffers= 0;
  393. _glStencilOpSeparate= 0;
  394. _glStencilFuncSeparate= 0;
  395. _glStencilMaskSeparate= 0;
  396. _glAttachShader= 0;
  397. _glBindAttribLocation= 0;
  398. _glCompileShader= 0;
  399. _glCreateProgram= 0;
  400. _glCreateShader= 0;
  401. _glDeleteProgram= 0;
  402. _glDeleteShader= 0;
  403. _glDetachShader= 0;
  404. _glDisableVertexAttribArray= 0;
  405. _glEnableVertexAttribArray= 0;
  406. _glGetActiveAttrib= 0;
  407. _glGetActiveUniform= 0;
  408. _glGetAttachedShaders= 0;
  409. _glGetAttribLocation= 0;
  410. _glGetProgramiv= 0;
  411. _glGetProgramInfoLog= 0;
  412. _glGetShaderiv= 0;
  413. _glGetShaderInfoLog= 0;
  414. _glGetShaderSource= 0;
  415. _glGetUniformLocation= 0;
  416. _glGetUniformfv= 0;
  417. _glGetUniformiv= 0;
  418. _glGetVertexAttribdv= 0;
  419. _glGetVertexAttribfv= 0;
  420. _glGetVertexAttribiv= 0;
  421. _glGetVertexAttribPointerv= 0;
  422. _glIsProgram= 0;
  423. _glIsShader= 0;
  424. _glLinkProgram= 0;
  425. _glShaderSource= 0;
  426. _glUseProgram= 0;
  427. _glUniform1f= 0;
  428. _glUniform2f= 0;
  429. _glUniform3f= 0;
  430. _glUniform4f= 0;
  431. _glUniform1i= 0;
  432. _glUniform2i= 0;
  433. _glUniform3i= 0;
  434. _glUniform4i= 0;
  435. _glUniform1fv= 0;
  436. _glUniform2fv= 0;
  437. _glUniform3fv= 0;
  438. _glUniform4fv= 0;
  439. _glUniform1iv= 0;
  440. _glUniform2iv= 0;
  441. _glUniform3iv= 0;
  442. _glUniform4iv= 0;
  443. _glUniformMatrix2fv= 0;
  444. _glUniformMatrix3fv= 0;
  445. _glUniformMatrix4fv= 0;
  446. _glValidateProgram= 0;
  447. _glVertexAttrib1d= 0;
  448. _glVertexAttrib1dv= 0;
  449. _glVertexAttrib1f= 0;
  450. _glVertexAttrib1fv= 0;
  451. _glVertexAttrib1s= 0;
  452. _glVertexAttrib1sv= 0;
  453. _glVertexAttrib2d= 0;
  454. _glVertexAttrib2dv= 0;
  455. _glVertexAttrib2f= 0;
  456. _glVertexAttrib2fv= 0;
  457. _glVertexAttrib2s= 0;
  458. _glVertexAttrib2sv= 0;
  459. _glVertexAttrib3d= 0;
  460. _glVertexAttrib3dv= 0;
  461. _glVertexAttrib3f= 0;
  462. _glVertexAttrib3fv= 0;
  463. _glVertexAttrib3s= 0;
  464. _glVertexAttrib3sv= 0;
  465. _glVertexAttrib4Nbv= 0;
  466. _glVertexAttrib4Niv= 0;
  467. _glVertexAttrib4Nsv= 0;
  468. _glVertexAttrib4Nub= 0;
  469. _glVertexAttrib4Nubv= 0;
  470. _glVertexAttrib4Nuiv= 0;
  471. _glVertexAttrib4Nusv= 0;
  472. _glVertexAttrib4bv= 0;
  473. _glVertexAttrib4d= 0;
  474. _glVertexAttrib4dv= 0;
  475. _glVertexAttrib4f= 0;
  476. _glVertexAttrib4fv= 0;
  477. _glVertexAttrib4iv= 0;
  478. _glVertexAttrib4s= 0;
  479. _glVertexAttrib4sv= 0;
  480. _glVertexAttrib4ubv= 0;
  481. _glVertexAttrib4uiv= 0;
  482. _glVertexAttrib4usv= 0;
  483. _glVertexAttribPointer= 0;
  484. _glGetInfoLogARB= 0;
  485. _glGetObjectParameterivARB= 0;
  486. _glDeleteObjectARB= 0;
  487. _glGetHandleARB= 0;
  488. // GL 2.1
  489. _glUniformMatrix2x3fv= 0;
  490. _glUniformMatrix3x2fv= 0;
  491. _glUniformMatrix2x4fv= 0;
  492. _glUniformMatrix4x2fv= 0;
  493. _glUniformMatrix3x4fv= 0;
  494. _glUniformMatrix4x3fv= 0;
  495. // EXT_geometry_shader4
  496. _glProgramParameteri= 0;
  497. _glFramebufferTexture= 0;
  498. _glFramebufferTextureLayer= 0;
  499. _glFramebufferTextureFace= 0;
  500. // ARB_tesselation_shader
  501. _glPatchParameteri= 0;
  502. _glPatchParameterfv= 0;
  503. // EXT_gpu_shader4
  504. _glGetUniformuiv= 0;
  505. _glBindFragDataLocation= 0;
  506. _glGetFragDataLocation= 0;
  507. _glUniform1ui= 0;
  508. _glUniform2ui= 0;
  509. _glUniform3ui= 0;
  510. _glUniform4ui= 0;
  511. _glUniform1uiv= 0;
  512. _glUniform2uiv= 0;
  513. _glUniform3uiv= 0;
  514. _glUniform4uiv= 0;
  515. // ARB_uniform_buffer_object
  516. _glGetUniformIndices= 0;
  517. _glGetActiveUniformsiv= 0;
  518. _glGetActiveUniformName= 0;
  519. _glGetUniformBlockIndex= 0;
  520. _glGetActiveUniformBlockiv= 0;
  521. _glGetActiveUniformBlockName= 0;
  522. _glUniformBlockBinding= 0;
  523. // ARB_get_program_binary
  524. _glGetProgramBinary= 0;
  525. _glProgramBinary= 0;
  526. // ARB_gpu_shader_fp64
  527. _glUniform1d= 0;
  528. _glUniform2d= 0;
  529. _glUniform3d= 0;
  530. _glUniform4d= 0;
  531. _glUniform1dv= 0;
  532. _glUniform2dv= 0;
  533. _glUniform3dv= 0;
  534. _glUniform4dv= 0;
  535. _glUniformMatrix2dv= 0;
  536. _glUniformMatrix3dv= 0;
  537. _glUniformMatrix4dv= 0;
  538. _glUniformMatrix2x3dv= 0;
  539. _glUniformMatrix3x2dv= 0;
  540. _glUniformMatrix2x4dv= 0;
  541. _glUniformMatrix4x2dv= 0;
  542. _glUniformMatrix3x4dv= 0;
  543. _glUniformMatrix4x3dv= 0;
  544. // ARB_shader_atomic_counters
  545. _glGetActiveAtomicCounterBufferiv= 0;
  546. return;
  547. }
  548. _glVersion = findAsciiToFloat( version );
  549. _glslLanguageVersion = 0.0f;
  550. bool shadersBuiltIn = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
  551. _isShaderObjectsSupported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects");
  552. _isVertexShaderSupported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader");
  553. _isFragmentShaderSupported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_fragment_shader");
  554. _isLanguage100Supported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_shading_language_100");
  555. _isGeometryShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_geometry_shader4");
  556. _isGpuShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_gpu_shader4");
  557. _areTessellationShadersSupported = osg::isGLExtensionSupported(contextID, "GL_ARB_tessellation_shader");
  558. _isUniformBufferObjectSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_uniform_buffer_object");
  559. _isGetProgramBinarySupported = osg::isGLExtensionSupported(contextID,"GL_ARB_get_program_binary");
  560. _isGpuShaderFp64Supported = osg::isGLExtensionSupported(contextID,"GL_ARB_gpu_shader_fp64");
  561. _isShaderAtomicCountersSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_atomic_counters");
  562. if( isGlslSupported() )
  563. {
  564. // If glGetString raises an error, assume initial release "1.00"
  565. while(glGetError() != GL_NO_ERROR) {} // reset error flag
  566. const char* langVerStr = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
  567. if( (glGetError() == GL_NO_ERROR) && langVerStr )
  568. {
  569. _glslLanguageVersion = (findAsciiToFloat(langVerStr));
  570. }
  571. else
  572. _glslLanguageVersion = 1.0f;
  573. }
  574. OSG_INFO
  575. << "glVersion=" << getGlVersion() << ", "
  576. << "isGlslSupported=" << (isGlslSupported() ? "YES" : "NO") << ", "
  577. << "glslLanguageVersion=" << getLanguageVersion()
  578. << std::endl;
  579. setGLExtensionFuncPtr(_glBlendEquationSeparate, "glBlendEquationSeparate");
  580. setGLExtensionFuncPtr(_glDrawBuffers, "glDrawBuffers", "glDrawBuffersARB");
  581. setGLExtensionFuncPtr(_glStencilOpSeparate, "glStencilOpSeparate");
  582. setGLExtensionFuncPtr(_glStencilFuncSeparate, "glStencilFuncSeparate");
  583. setGLExtensionFuncPtr(_glStencilMaskSeparate, "glStencilMaskSeparate");
  584. setGLExtensionFuncPtr(_glAttachShader, "glAttachShader", "glAttachObjectARB");
  585. setGLExtensionFuncPtr(_glBindAttribLocation, "glBindAttribLocation", "glBindAttribLocationARB");
  586. setGLExtensionFuncPtr(_glCompileShader, "glCompileShader", "glCompileShaderARB");
  587. setGLExtensionFuncPtr(_glCreateProgram, "glCreateProgram", "glCreateProgramObjectARB");
  588. setGLExtensionFuncPtr(_glCreateShader, "glCreateShader", "glCreateShaderObjectARB");
  589. setGLExtensionFuncPtr(_glDeleteProgram, "glDeleteProgram");
  590. setGLExtensionFuncPtr(_glDeleteShader, "glDeleteShader");
  591. setGLExtensionFuncPtr(_glDetachShader, "glDetachShader", "glDetachObjectARB");
  592. setGLExtensionFuncPtr(_glDisableVertexAttribArray, "glDisableVertexAttribArray");
  593. setGLExtensionFuncPtr(_glEnableVertexAttribArray, "glEnableVertexAttribArray");
  594. setGLExtensionFuncPtr(_glGetActiveAttrib, "glGetActiveAttrib", "glGetActiveAttribARB");
  595. setGLExtensionFuncPtr(_glGetActiveUniform, "glGetActiveUniform", "glGetActiveUniformARB");
  596. setGLExtensionFuncPtr(_glGetAttachedShaders, "glGetAttachedShaders", "glGetAttachedObjectsARB");
  597. setGLExtensionFuncPtr(_glGetAttribLocation, "glGetAttribLocation", "glGetAttribLocationARB");
  598. setGLExtensionFuncPtr(_glGetProgramiv, "glGetProgramiv");
  599. setGLExtensionFuncPtr(_glGetProgramInfoLog, "glGetProgramInfoLog");
  600. setGLExtensionFuncPtr(_glGetShaderiv, "glGetShaderiv");
  601. setGLExtensionFuncPtr(_glGetShaderInfoLog, "glGetShaderInfoLog");
  602. setGLExtensionFuncPtr(_glGetShaderSource, "glGetShaderSource", "glGetShaderSourceARB");
  603. setGLExtensionFuncPtr(_glGetUniformLocation, "glGetUniformLocation", "glGetUniformLocationARB");
  604. setGLExtensionFuncPtr(_glGetUniformfv, "glGetUniformfv", "glGetUniformfvARB");
  605. setGLExtensionFuncPtr(_glGetUniformiv, "glGetUniformiv", "glGetUniformivARB");
  606. setGLExtensionFuncPtr(_glGetVertexAttribdv, "glGetVertexAttribdv");
  607. setGLExtensionFuncPtr(_glGetVertexAttribfv, "glGetVertexAttribfv");
  608. setGLExtensionFuncPtr(_glGetVertexAttribiv, "glGetVertexAttribiv");
  609. setGLExtensionFuncPtr(_glGetVertexAttribPointerv, "glGetVertexAttribPointerv");
  610. setGLExtensionFuncPtr(_glIsProgram, "glIsProgram");
  611. setGLExtensionFuncPtr(_glIsShader, "glIsShader");
  612. setGLExtensionFuncPtr(_glLinkProgram, "glLinkProgram", "glLinkProgramARB");
  613. setGLExtensionFuncPtr(_glShaderSource, "glShaderSource", "glShaderSourceARB");
  614. setGLExtensionFuncPtr(_glUseProgram, "glUseProgram", "glUseProgramObjectARB");
  615. setGLExtensionFuncPtr(_glUniform1f, "glUniform1f", "glUniform1fARB");
  616. setGLExtensionFuncPtr(_glUniform2f, "glUniform2f", "glUniform2fARB");
  617. setGLExtensionFuncPtr(_glUniform3f, "glUniform3f", "glUniform3fARB");
  618. setGLExtensionFuncPtr(_glUniform4f, "glUniform4f", "glUniform4fARB");
  619. setGLExtensionFuncPtr(_glUniform1i, "glUniform1i", "glUniform1iARB");
  620. setGLExtensionFuncPtr(_glUniform2i, "glUniform2i", "glUniform2iARB");
  621. setGLExtensionFuncPtr(_glUniform3i, "glUniform3i", "glUniform3iARB");
  622. setGLExtensionFuncPtr(_glUniform4i, "glUniform4i", "glUniform4iARB");
  623. setGLExtensionFuncPtr(_glUniform1fv, "glUniform1fv", "glUniform1fvARB");
  624. setGLExtensionFuncPtr(_glUniform2fv, "glUniform2fv", "glUniform2fvARB");
  625. setGLExtensionFuncPtr(_glUniform3fv, "glUniform3fv", "glUniform3fvARB");
  626. setGLExtensionFuncPtr(_glUniform4fv, "glUniform4fv", "glUniform4fvARB");
  627. setGLExtensionFuncPtr(_glUniform1iv, "glUniform1iv", "glUniform1ivARB");
  628. setGLExtensionFuncPtr(_glUniform2iv, "glUniform2iv", "glUniform2ivARB");
  629. setGLExtensionFuncPtr(_glUniform3iv, "glUniform3iv", "glUniform3ivARB");
  630. setGLExtensionFuncPtr(_glUniform4iv, "glUniform4iv", "glUniform4ivARB");
  631. setGLExtensionFuncPtr(_glUniformMatrix2fv, "glUniformMatrix2fv", "glUniformMatrix2fvARB");
  632. setGLExtensionFuncPtr(_glUniformMatrix3fv, "glUniformMatrix3fv", "glUniformMatrix3fvARB");
  633. setGLExtensionFuncPtr(_glUniformMatrix4fv, "glUniformMatrix4fv", "glUniformMatrix4fvARB");
  634. setGLExtensionFuncPtr(_glValidateProgram, "glValidateProgram", "glValidateProgramARB");
  635. setGLExtensionFuncPtr(_glVertexAttrib1d, "glVertexAttrib1d");
  636. setGLExtensionFuncPtr(_glVertexAttrib1dv, "glVertexAttrib1dv");
  637. setGLExtensionFuncPtr(_glVertexAttrib1f, "glVertexAttrib1f");
  638. setGLExtensionFuncPtr(_glVertexAttrib1fv, "glVertexAttrib1fv");
  639. setGLExtensionFuncPtr(_glVertexAttrib1s, "glVertexAttrib1s");
  640. setGLExtensionFuncPtr(_glVertexAttrib1sv, "glVertexAttrib1sv");
  641. setGLExtensionFuncPtr(_glVertexAttrib2d, "glVertexAttrib2d");
  642. setGLExtensionFuncPtr(_glVertexAttrib2dv, "glVertexAttrib2dv");
  643. setGLExtensionFuncPtr(_glVertexAttrib2f, "glVertexAttrib2f");
  644. setGLExtensionFuncPtr(_glVertexAttrib2fv, "glVertexAttrib2fv");
  645. setGLExtensionFuncPtr(_glVertexAttrib2s, "glVertexAttrib2s");
  646. setGLExtensionFuncPtr(_glVertexAttrib2sv, "glVertexAttrib2sv");
  647. setGLExtensionFuncPtr(_glVertexAttrib3d, "glVertexAttrib3d");
  648. setGLExtensionFuncPtr(_glVertexAttrib3dv, "glVertexAttrib3dv");
  649. setGLExtensionFuncPtr(_glVertexAttrib3f, "glVertexAttrib3f");
  650. setGLExtensionFuncPtr(_glVertexAttrib3fv, "glVertexAttrib3fv");
  651. setGLExtensionFuncPtr(_glVertexAttrib3s, "glVertexAttrib3s");
  652. setGLExtensionFuncPtr(_glVertexAttrib3sv, "glVertexAttrib3sv");
  653. setGLExtensionFuncPtr(_glVertexAttrib4Nbv, "glVertexAttrib4Nbv");
  654. setGLExtensionFuncPtr(_glVertexAttrib4Niv, "glVertexAttrib4Niv");
  655. setGLExtensionFuncPtr(_glVertexAttrib4Nsv, "glVertexAttrib4Nsv");
  656. setGLExtensionFuncPtr(_glVertexAttrib4Nub, "glVertexAttrib4Nub");
  657. setGLExtensionFuncPtr(_glVertexAttrib4Nubv, "glVertexAttrib4Nubv");
  658. setGLExtensionFuncPtr(_glVertexAttrib4Nuiv, "glVertexAttrib4Nuiv");
  659. setGLExtensionFuncPtr(_glVertexAttrib4Nusv, "glVertexAttrib4Nusv");
  660. setGLExtensionFuncPtr(_glVertexAttrib4bv, "glVertexAttrib4bv");
  661. setGLExtensionFuncPtr(_glVertexAttrib4d, "glVertexAttrib4d");
  662. setGLExtensionFuncPtr(_glVertexAttrib4dv, "glVertexAttrib4dv");
  663. setGLExtensionFuncPtr(_glVertexAttrib4f, "glVertexAttrib4f");
  664. setGLExtensionFuncPtr(_glVertexAttrib4fv, "glVertexAttrib4fv");
  665. setGLExtensionFuncPtr(_glVertexAttrib4iv, "glVertexAttrib4iv");
  666. setGLExtensionFuncPtr(_glVertexAttrib4s, "glVertexAttrib4s");
  667. setGLExtensionFuncPtr(_glVertexAttrib4sv, "glVertexAttrib4sv");
  668. setGLExtensionFuncPtr(_glVertexAttrib4ubv, "glVertexAttrib4ubv");
  669. setGLExtensionFuncPtr(_glVertexAttrib4uiv, "glVertexAttrib4uiv");
  670. setGLExtensionFuncPtr(_glVertexAttrib4usv, "glVertexAttrib4usv");
  671. setGLExtensionFuncPtr(_glVertexAttribPointer, "glVertexAttribPointer");
  672. // v1.5-only ARB entry points, in case they're needed for fallback
  673. setGLExtensionFuncPtr(_glGetInfoLogARB, "glGetInfoLogARB");
  674. setGLExtensionFuncPtr(_glGetObjectParameterivARB, "glGetObjectParameterivARB");
  675. setGLExtensionFuncPtr(_glDeleteObjectARB, "glDeleteObjectARB");
  676. setGLExtensionFuncPtr(_glGetHandleARB, "glGetHandleARB");
  677. // GL 2.1
  678. setGLExtensionFuncPtr(_glUniformMatrix2x3fv, "glUniformMatrix2x3fv" );
  679. setGLExtensionFuncPtr(_glUniformMatrix3x2fv, "glUniformMatrix3x2fv" );
  680. setGLExtensionFuncPtr(_glUniformMatrix2x4fv, "glUniformMatrix2x4fv" );
  681. setGLExtensionFuncPtr(_glUniformMatrix4x2fv, "glUniformMatrix4x2fv" );
  682. setGLExtensionFuncPtr(_glUniformMatrix3x4fv, "glUniformMatrix3x4fv" );
  683. setGLExtensionFuncPtr(_glUniformMatrix4x3fv, "glUniformMatrix4x3fv" );
  684. // EXT_geometry_shader4
  685. setGLExtensionFuncPtr(_glProgramParameteri, "glProgramParameteri", "glProgramParameteriEXT" );
  686. setGLExtensionFuncPtr(_glFramebufferTexture, "glFramebufferTexture", "glFramebufferTextureEXT" );
  687. setGLExtensionFuncPtr(_glFramebufferTextureLayer, "glFramebufferTextureLayer", "glFramebufferTextureLayerEXT" );
  688. setGLExtensionFuncPtr(_glFramebufferTextureFace, "glFramebufferTextureFace", "glFramebufferTextureFaceEXT" );
  689. // ARB_tesselation_shader
  690. setGLExtensionFuncPtr(_glPatchParameteri, "glPatchParameteri" );
  691. setGLExtensionFuncPtr(_glPatchParameterfv, "glPatchParameterfv");
  692. // EXT_gpu_shader4
  693. setGLExtensionFuncPtr(_glGetUniformuiv, "glGetUniformuiv", "glGetUniformuivEXT" );
  694. setGLExtensionFuncPtr(_glBindFragDataLocation, "glBindFragDataLocation", "glBindFragDataLocationEXT" );
  695. setGLExtensionFuncPtr(_glGetFragDataLocation, "glGetFragDataLocation", "glGetFragDataLocationEXT" );
  696. setGLExtensionFuncPtr(_glUniform1ui, "glUniform1ui", "glUniform1uiEXT" );
  697. setGLExtensionFuncPtr(_glUniform2ui, "glUniform2ui", "glUniform2uiEXT" );
  698. setGLExtensionFuncPtr(_glUniform3ui, "glUniform3ui", "glUniform3uiEXT" );
  699. setGLExtensionFuncPtr(_glUniform4ui, "glUniform4ui", "glUniform4uiEXT" );
  700. setGLExtensionFuncPtr(_glUniform1uiv, "glUniform1uiv", "glUniform1uivEXT" );
  701. setGLExtensionFuncPtr(_glUniform2uiv, "glUniform2uiv", "glUniform2uivEXT" );
  702. setGLExtensionFuncPtr(_glUniform3uiv, "glUniform3uiv", "glUniform3uivEXT" );
  703. setGLExtensionFuncPtr(_glUniform4uiv, "glUniform4uiv", "glUniform4uivEXT" );
  704. // ARB_uniform_buffer_object
  705. setGLExtensionFuncPtr(_glGetUniformIndices, "glGetUniformIndices");
  706. setGLExtensionFuncPtr(_glGetActiveUniformsiv, "glGetActiveUniformsiv");
  707. setGLExtensionFuncPtr(_glGetActiveUniformName, "glGetActiveUniformName");
  708. setGLExtensionFuncPtr(_glGetUniformBlockIndex, "glGetUniformBlockIndex");
  709. setGLExtensionFuncPtr(_glGetActiveUniformBlockiv, "glGetActiveUniformBlockiv");
  710. setGLExtensionFuncPtr(_glGetActiveUniformBlockName, "glGetActiveUniformBlockName");
  711. setGLExtensionFuncPtr(_glUniformBlockBinding, "glUniformBlockBinding");
  712. // ARB_get_program_binary
  713. setGLExtensionFuncPtr(_glGetProgramBinary, "glGetProgramBinary");
  714. setGLExtensionFuncPtr(_glProgramBinary, "glProgramBinary");
  715. // ARB_gpu_shader_fp64
  716. setGLExtensionFuncPtr(_glUniform1d, "glUniform1d" );
  717. setGLExtensionFuncPtr(_glUniform2d, "glUniform2d" );
  718. setGLExtensionFuncPtr(_glUniform3d, "glUniform3d" );
  719. setGLExtensionFuncPtr(_glUniform4d, "glUniform4d" );
  720. setGLExtensionFuncPtr(_glUniform1dv, "glUniform1dv" );
  721. setGLExtensionFuncPtr(_glUniform2dv, "glUniform2dv" );
  722. setGLExtensionFuncPtr(_glUniform3dv, "glUniform3dv" );
  723. setGLExtensionFuncPtr(_glUniform4dv, "glUniform4dv" );
  724. setGLExtensionFuncPtr(_glUniformMatrix2dv, "glUniformMatrix2dv" );
  725. setGLExtensionFuncPtr(_glUniformMatrix3dv, "glUniformMatrix3dv" );
  726. setGLExtensionFuncPtr(_glUniformMatrix4dv, "glUniformMatrix4dv" );
  727. setGLExtensionFuncPtr(_glUniformMatrix2x3dv, "glUniformMatrix2x3dv" );
  728. setGLExtensionFuncPtr(_glUniformMatrix3x2dv, "glUniformMatrix3x2dv" );
  729. setGLExtensionFuncPtr(_glUniformMatrix2x4dv, "glUniformMatrix2x4dv" );
  730. setGLExtensionFuncPtr(_glUniformMatrix4x2dv, "glUniformMatrix4x2dv" );
  731. setGLExtensionFuncPtr(_glUniformMatrix3x4dv, "glUniformMatrix3x4dv" );
  732. setGLExtensionFuncPtr(_glUniformMatrix4x3dv, "glUniformMatrix4x3dv" );
  733. // ARB_shader_atomic_counters
  734. setGLExtensionFuncPtr(_glGetActiveAtomicCounterBufferiv, "glGetActiveAtomicCounterBufferiv" );
  735. }
  736. bool GL2Extensions::isGlslSupported() const
  737. {
  738. return ( _glVersion >= 2.0f ) ||
  739. ( _isShaderObjectsSupported &&
  740. _isVertexShaderSupported &&
  741. _isFragmentShaderSupported &&
  742. _isLanguage100Supported );
  743. }
  744. ///////////////////////////////////////////////////////////////////////////
  745. // Static array of per-context osg::GL2Extensions instances
  746. typedef osg::buffered_object< osg::ref_ptr<GL2Extensions> > BufferedExtensions;
  747. static BufferedExtensions s_extensions;
  748. GL2Extensions* GL2Extensions::Get(unsigned int contextID, bool createIfNotInitalized)
  749. {
  750. if (!s_extensions[contextID] && createIfNotInitalized)
  751. s_extensions[contextID] = new GL2Extensions(contextID);
  752. return s_extensions[contextID].get();
  753. }
  754. void GL2Extensions::Set(unsigned int contextID, GL2Extensions* extensions)
  755. {
  756. s_extensions[contextID] = extensions;
  757. }
  758. ///////////////////////////////////////////////////////////////////////////
  759. static void NotSupported( const char* funcName )
  760. {
  761. OSG_WARN
  762. <<"Error: "<<funcName<<" not supported by OpenGL driver"<<std::endl;
  763. }
  764. void GL2Extensions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) const
  765. {
  766. if (_glBlendEquationSeparate)
  767. {
  768. _glBlendEquationSeparate(modeRGB, modeAlpha);
  769. }
  770. else
  771. {
  772. NotSupported( "glBlendEquationSeparate" );
  773. }
  774. }
  775. void GL2Extensions::glDrawBuffers(GLsizei n, const GLenum *bufs) const
  776. {
  777. if (_glDrawBuffers)
  778. {
  779. _glDrawBuffers(n, bufs);
  780. }
  781. else
  782. {
  783. NotSupported( "glDrawBuffers" );
  784. }
  785. }
  786. void GL2Extensions::glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) const
  787. {
  788. if (_glStencilOpSeparate)
  789. {
  790. _glStencilOpSeparate(face, sfail, dpfail, dppass);
  791. }
  792. else
  793. {
  794. NotSupported( "glStencilOpSeparate" );
  795. }
  796. }
  797. void GL2Extensions::glStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) const
  798. {
  799. if (_glStencilFuncSeparate)
  800. {
  801. _glStencilFuncSeparate(frontfunc, backfunc, ref, mask);
  802. }
  803. else
  804. {
  805. NotSupported( "glStencilFuncSeparate" );
  806. }
  807. }
  808. void GL2Extensions::glStencilMaskSeparate(GLenum face, GLuint mask) const
  809. {
  810. if (_glStencilMaskSeparate)
  811. {
  812. _glStencilMaskSeparate(face, mask);
  813. }
  814. else
  815. {
  816. NotSupported( "glStencilMaskSeparate" );
  817. }
  818. }
  819. void GL2Extensions::glAttachShader(GLuint program, GLuint shader) const
  820. {
  821. if (_glAttachShader)
  822. {
  823. _glAttachShader(program, shader);
  824. }
  825. else
  826. {
  827. NotSupported( "glAttachShader" );
  828. }
  829. }
  830. void GL2Extensions::glBindAttribLocation(GLuint program, GLuint index, const GLchar *name) const
  831. {
  832. if (_glBindAttribLocation)
  833. {
  834. _glBindAttribLocation(program, index, name);
  835. }
  836. else
  837. {
  838. NotSupported( "glBindAttribLocation" );
  839. }
  840. }
  841. void GL2Extensions::glCompileShader(GLuint shader) const
  842. {
  843. if (_glCompileShader)
  844. {
  845. _glCompileShader(shader);
  846. }
  847. else
  848. {
  849. NotSupported( "glCompileShader" );
  850. }
  851. }
  852. GLuint GL2Extensions::glCreateProgram(void) const
  853. {
  854. if (_glCreateProgram)
  855. {
  856. return _glCreateProgram();
  857. }
  858. else
  859. {
  860. NotSupported( "glCreateProgram" );
  861. return 0;
  862. }
  863. }
  864. GLuint GL2Extensions::glCreateShader(GLenum type) const
  865. {
  866. if (_glCreateShader)
  867. {
  868. return _glCreateShader(type);
  869. }
  870. else
  871. {
  872. NotSupported( "glCreateShader" );
  873. return 0;
  874. }
  875. }
  876. void GL2Extensions::glDeleteProgram(GLuint program) const
  877. {
  878. if (_glDeleteProgram)
  879. {
  880. _glDeleteProgram(program);
  881. }
  882. else if (_glDeleteObjectARB)
  883. {
  884. _glDeleteObjectARB(program);
  885. }
  886. else
  887. {
  888. NotSupported( "glDeleteProgram" );
  889. }
  890. }
  891. void GL2Extensions::glDeleteShader(GLuint shader) const
  892. {
  893. if (_glDeleteShader)
  894. {
  895. _glDeleteShader(shader);
  896. }
  897. else if (_glDeleteObjectARB)
  898. {
  899. _glDeleteObjectARB(shader);
  900. }
  901. else
  902. {
  903. NotSupported( "glDeleteShader" );
  904. }
  905. }
  906. void GL2Extensions::glDetachShader(GLuint program, GLuint shader) const
  907. {
  908. if (_glDetachShader)
  909. {
  910. _glDetachShader(program, shader);
  911. }
  912. else
  913. {
  914. NotSupported( "glDetachShader" );
  915. }
  916. }
  917. void GL2Extensions::glDisableVertexAttribArray(GLuint index) const
  918. {
  919. if (_glDisableVertexAttribArray)
  920. {
  921. _glDisableVertexAttribArray(index);
  922. }
  923. else
  924. {
  925. NotSupported( "glDisableVertexAttribArray" );
  926. }
  927. }
  928. void GL2Extensions::glEnableVertexAttribArray(GLuint index) const
  929. {
  930. if (_glEnableVertexAttribArray)
  931. {
  932. _glEnableVertexAttribArray(index);
  933. }
  934. else
  935. {
  936. NotSupported( "glEnableVertexAttribArray" );
  937. }
  938. }
  939. void GL2Extensions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const
  940. {
  941. if (_glGetActiveAttrib)
  942. {
  943. _glGetActiveAttrib(program, index, bufSize, length, size, type, name);
  944. }
  945. else
  946. {
  947. NotSupported( "glGetActiveAttrib" );
  948. }
  949. }
  950. void GL2Extensions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const
  951. {
  952. if (_glGetActiveUniform)
  953. {
  954. _glGetActiveUniform(program, index, bufSize, length, size, type, name);
  955. }
  956. else
  957. {
  958. NotSupported( "glGetActiveUniform" );
  959. }
  960. }
  961. void GL2Extensions::glGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj) const
  962. {
  963. if (_glGetAttachedShaders)
  964. {
  965. _glGetAttachedShaders(program, maxCount, count, obj);
  966. }
  967. else
  968. {
  969. NotSupported( "glGetAttachedShaders" );
  970. }
  971. }
  972. GLint GL2Extensions::glGetAttribLocation(GLuint program, const GLchar *name) const
  973. {
  974. if (_glGetAttribLocation)
  975. {
  976. return _glGetAttribLocation(program, name);
  977. }
  978. else
  979. {
  980. NotSupported( "glGetAttribLocation" );
  981. return 0;
  982. }
  983. }
  984. void GL2Extensions::glGetProgramiv(GLuint program, GLenum pname, GLint *params) const
  985. {
  986. if (_glGetProgramiv)
  987. {
  988. _glGetProgramiv(program, pname, params);
  989. }
  990. else if (_glGetObjectParameterivARB)
  991. {
  992. _glGetObjectParameterivARB(program, pname, params);
  993. }
  994. else
  995. {
  996. NotSupported( "glGetProgramiv" );
  997. }
  998. }
  999. void GL2Extensions::glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const
  1000. {
  1001. if (_glGetProgramInfoLog)
  1002. {
  1003. _glGetProgramInfoLog(program, bufSize, length, infoLog);
  1004. }
  1005. else if (_glGetInfoLogARB)
  1006. {
  1007. _glGetInfoLogARB(program, bufSize, length, infoLog);
  1008. }
  1009. else
  1010. {
  1011. NotSupported( "glGetProgramInfoLog" );
  1012. }
  1013. }
  1014. void GL2Extensions::glGetShaderiv(GLuint shader, GLenum pname, GLint *params) const
  1015. {
  1016. if (_glGetShaderiv)
  1017. {
  1018. _glGetShaderiv(shader, pname, params);
  1019. }
  1020. else if (_glGetObjectParameterivARB)
  1021. {
  1022. _glGetObjectParameterivARB(shader, pname, params);
  1023. }
  1024. else
  1025. {
  1026. NotSupported( "glGetShaderiv" );
  1027. }
  1028. }
  1029. void GL2Extensions::glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const
  1030. {
  1031. if (_glGetShaderInfoLog)
  1032. {
  1033. _glGetShaderInfoLog(shader, bufSize, length, infoLog);
  1034. }
  1035. else if (_glGetInfoLogARB)
  1036. {
  1037. _glGetInfoLogARB(shader, bufSize, length, infoLog);
  1038. }
  1039. else
  1040. {
  1041. NotSupported( "glGetShaderInfoLog" );
  1042. }
  1043. }
  1044. void GL2Extensions::glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) const
  1045. {
  1046. if (_glGetShaderSource)
  1047. {
  1048. _glGetShaderSource(shader, bufSize, length, source);
  1049. }
  1050. else
  1051. {
  1052. NotSupported( "glGetShaderSource" );
  1053. }
  1054. }
  1055. GLint GL2Extensions::glGetUniformLocation(GLuint program, const GLchar *name) const
  1056. {
  1057. if (_glGetUniformLocation)
  1058. {
  1059. return _glGetUniformLocation(program, name);
  1060. }
  1061. else
  1062. {
  1063. NotSupported( "glGetUniformLocation" );
  1064. return 0;
  1065. }
  1066. }
  1067. void GL2Extensions::glGetUniformfv(GLuint program, GLint location, GLfloat *params) const
  1068. {
  1069. if (_glGetUniformfv)
  1070. {
  1071. _glGetUniformfv(program, location, params);
  1072. }
  1073. else
  1074. {
  1075. NotSupported( "glGetUniformfv" );
  1076. }
  1077. }
  1078. void GL2Extensions::glGetUniformiv(GLuint program, GLint location, GLint *params) const
  1079. {
  1080. if (_glGetUniformiv)
  1081. {
  1082. _glGetUniformiv(program, location, params);
  1083. }
  1084. else
  1085. {
  1086. NotSupported( "glGetUniformiv" );
  1087. }
  1088. }
  1089. void GL2Extensions::glGetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params) const
  1090. {
  1091. if (_glGetVertexAttribdv)
  1092. {
  1093. _glGetVertexAttribdv(index, pname, params);
  1094. }
  1095. else
  1096. {
  1097. NotSupported( "glGetVertexAttribdv" );
  1098. }
  1099. }
  1100. void GL2Extensions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) const
  1101. {
  1102. if (_glGetVertexAttribfv)
  1103. {
  1104. _glGetVertexAttribfv(index, pname, params);
  1105. }
  1106. else
  1107. {
  1108. NotSupported( "glGetVertexAttribfv" );
  1109. }
  1110. }
  1111. void GL2Extensions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params) const
  1112. {
  1113. if (_glGetVertexAttribiv)
  1114. {
  1115. _glGetVertexAttribiv(index, pname, params);
  1116. }
  1117. else
  1118. {
  1119. NotSupported( "glGetVertexAttribiv" );
  1120. }
  1121. }
  1122. void GL2Extensions::glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid* *pointer) const
  1123. {
  1124. if (_glGetVertexAttribPointerv)
  1125. {
  1126. _glGetVertexAttribPointerv(index, pname, pointer);
  1127. }
  1128. else
  1129. {
  1130. NotSupported( "glGetVertexAttribPointerv" );
  1131. }
  1132. }
  1133. GLboolean GL2Extensions::glIsProgram(GLuint program) const
  1134. {
  1135. if (_glIsProgram)
  1136. {
  1137. return _glIsProgram(program);
  1138. }
  1139. else
  1140. {
  1141. NotSupported( "glIsProgram" );
  1142. return 0;
  1143. }
  1144. }
  1145. GLboolean GL2Extensions::glIsShader(GLuint shader) const
  1146. {
  1147. if (_glIsShader)
  1148. {
  1149. return _glIsShader(shader);
  1150. }
  1151. else
  1152. {
  1153. NotSupported( "glIsShader" );
  1154. return 0;
  1155. }
  1156. }
  1157. void GL2Extensions::glLinkProgram(GLuint program) const
  1158. {
  1159. if (_glLinkProgram)
  1160. {
  1161. _glLinkProgram(program);
  1162. }
  1163. else
  1164. {
  1165. NotSupported( "glLinkProgram" );
  1166. }
  1167. }
  1168. void GL2Extensions::glShaderSource(GLuint shader, GLsizei count, const GLchar* *string, const GLint *length) const
  1169. {
  1170. if (_glShaderSource)
  1171. {
  1172. _glShaderSource(shader, count, string, length);
  1173. }
  1174. else
  1175. {
  1176. NotSupported( "glShaderSource" );
  1177. }
  1178. }
  1179. void GL2Extensions::glUseProgram(GLuint program) const
  1180. {
  1181. if (_glUseProgram)
  1182. {
  1183. _glUseProgram(program);
  1184. }
  1185. else
  1186. {
  1187. NotSupported( "glUseProgram" );
  1188. }
  1189. }
  1190. void GL2Extensions::glUniform1f(GLint location, GLfloat v0) const
  1191. {
  1192. if (_glUniform1f)
  1193. {
  1194. _glUniform1f(location, v0);
  1195. }
  1196. else
  1197. {
  1198. NotSupported( "glUniform1f" );
  1199. }
  1200. }
  1201. void GL2Extensions::glUniform2f(GLint location, GLfloat v0, GLfloat v1) const
  1202. {
  1203. if (_glUniform2f)
  1204. {
  1205. _glUniform2f(location, v0, v1);
  1206. }
  1207. else
  1208. {
  1209. NotSupported( "glUniform2f" );
  1210. }
  1211. }
  1212. void GL2Extensions::glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) const
  1213. {
  1214. if (_glUniform3f)
  1215. {
  1216. _glUniform3f(location, v0, v1, v2);
  1217. }
  1218. else
  1219. {
  1220. NotSupported( "glUniform3f" );
  1221. }
  1222. }
  1223. void GL2Extensions::glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const
  1224. {
  1225. if (_glUniform4f)
  1226. {
  1227. _glUniform4f(location, v0, v1, v2, v3);
  1228. }
  1229. else
  1230. {
  1231. NotSupported( "glUniform4f" );
  1232. }
  1233. }
  1234. void GL2Extensions::glUniform1i(GLint location, GLint v0) const
  1235. {
  1236. if (_glUniform1i)
  1237. {
  1238. _glUniform1i(location, v0);
  1239. }
  1240. else
  1241. {
  1242. NotSupported( "glUniform1i" );
  1243. }
  1244. }
  1245. void GL2Extensions::glUniform2i(GLint location, GLint v0, GLint v1) const
  1246. {
  1247. if (_glUniform2i)
  1248. {
  1249. _glUniform2i(location, v0, v1);
  1250. }
  1251. else
  1252. {
  1253. NotSupported( "glUniform2i" );
  1254. }
  1255. }
  1256. void GL2Extensions::glUniform3i(GLint location, GLint v0, GLint v1, GLint v2) const
  1257. {
  1258. if (_glUniform3i)
  1259. {
  1260. _glUniform3i(location, v0, v1, v2);
  1261. }
  1262. else
  1263. {
  1264. NotSupported( "glUniform3i" );
  1265. }
  1266. }
  1267. void GL2Extensions::glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) const
  1268. {
  1269. if (_glUniform4i)
  1270. {
  1271. _glUniform4i(location, v0, v1, v2, v3);
  1272. }
  1273. else
  1274. {
  1275. NotSupported( "glUniform4i" );
  1276. }
  1277. }
  1278. void GL2Extensions::glUniform1fv(GLint location, GLsizei count, const GLfloat *value) const
  1279. {
  1280. if (_glUniform1fv)
  1281. {
  1282. _glUniform1fv(location, count, value);
  1283. }
  1284. else
  1285. {
  1286. NotSupported( "glUniform1fv" );
  1287. }
  1288. }
  1289. void GL2Extensions::glUniform2fv(GLint location, GLsizei count, const GLfloat *value) const
  1290. {
  1291. if (_glUniform2fv)
  1292. {
  1293. _glUniform2fv(location, count, value);
  1294. }
  1295. else
  1296. {
  1297. NotSupported( "glUniform2fv" );
  1298. }
  1299. }
  1300. void GL2Extensions::glUniform3fv(GLint location, GLsizei count, const GLfloat *value) const
  1301. {
  1302. if (_glUniform3fv)
  1303. {
  1304. _glUniform3fv(location, count, value);
  1305. }
  1306. else
  1307. {
  1308. NotSupported( "glUniform3fv" );
  1309. }
  1310. }
  1311. void GL2Extensions::glUniform4fv(GLint location, GLsizei count, const GLfloat *value) const
  1312. {
  1313. if (_glUniform4fv)
  1314. {
  1315. _glUniform4fv(location, count, value);
  1316. }
  1317. else
  1318. {
  1319. NotSupported( "glUniform4fv" );
  1320. }
  1321. }
  1322. void GL2Extensions::glUniform1iv(GLint location, GLsizei count, const GLint *value) const
  1323. {
  1324. if (_glUniform1iv)
  1325. {
  1326. _glUniform1iv(location, count, value);
  1327. }
  1328. else
  1329. {
  1330. NotSupported( "glUniform1iv" );
  1331. }
  1332. }
  1333. void GL2Extensions::glUniform2iv(GLint location, GLsizei count, const GLint *value) const
  1334. {
  1335. if (_glUniform2iv)
  1336. {
  1337. _glUniform2iv(location, count, value);
  1338. }
  1339. else
  1340. {
  1341. NotSupported( "glUniform2iv" );
  1342. }
  1343. }
  1344. void GL2Extensions::glUniform3iv(GLint location, GLsizei count, const GLint *value) const
  1345. {
  1346. if (_glUniform3iv)
  1347. {
  1348. _glUniform3iv(location, count, value);
  1349. }
  1350. else
  1351. {
  1352. NotSupported( "glUniform3iv" );
  1353. }
  1354. }
  1355. void GL2Extensions::glUniform4iv(GLint location, GLsizei count, const GLint *value) const
  1356. {
  1357. if (_glUniform4iv)
  1358. {
  1359. _glUniform4iv(location, count, value);
  1360. }
  1361. else
  1362. {
  1363. NotSupported( "glUniform4iv" );
  1364. }
  1365. }
  1366. void GL2Extensions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const
  1367. {
  1368. if (_glUniformMatrix2fv)
  1369. {
  1370. _glUniformMatrix2fv(location, count, transpose, value);
  1371. }
  1372. else
  1373. {
  1374. NotSupported( "glUniformMatrix2fv" );
  1375. }
  1376. }
  1377. void GL2Extensions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const
  1378. {
  1379. if (_glUniformMatrix3fv)
  1380. {
  1381. _glUniformMatrix3fv(location, count, transpose, value);
  1382. }
  1383. else
  1384. {
  1385. NotSupported( "glUniformMatrix3fv" );
  1386. }
  1387. }
  1388. void GL2Extensions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const
  1389. {
  1390. if (_glUniformMatrix4fv)
  1391. {
  1392. _glUniformMatrix4fv(location, count, transpose, value);
  1393. }
  1394. else
  1395. {
  1396. NotSupported( "glUniformMatrix4fv" );
  1397. }
  1398. }
  1399. void GL2Extensions::glValidateProgram(GLuint program) const
  1400. {
  1401. if (_glValidateProgram)
  1402. {
  1403. _glValidateProgram(program);
  1404. }
  1405. else
  1406. {
  1407. NotSupported( "glValidateProgram" );
  1408. }
  1409. }
  1410. void GL2Extensions::glVertexAttrib1d(GLuint index, GLdouble x) const
  1411. {
  1412. if (_glVertexAttrib1d)
  1413. {
  1414. _glVertexAttrib1d(index, x);
  1415. }
  1416. else
  1417. {
  1418. NotSupported( "glVertexAttrib1d" );
  1419. }
  1420. }
  1421. void GL2Extensions::glVertexAttrib1dv(GLuint index, const GLdouble *v) const
  1422. {
  1423. if (_glVertexAttrib1dv)
  1424. {
  1425. _glVertexAttrib1dv(index, v);
  1426. }
  1427. else
  1428. {
  1429. NotSupported( "glVertexAttrib1dv" );
  1430. }
  1431. }
  1432. void GL2Extensions::glVertexAttrib1f(GLuint index, GLfloat x) const
  1433. {
  1434. if (_glVertexAttrib1f)
  1435. {
  1436. _glVertexAttrib1f(index, x);
  1437. }
  1438. else
  1439. {
  1440. NotSupported( "glVertexAttrib1f" );
  1441. }
  1442. }
  1443. void GL2Extensions::glVertexAttrib1fv(GLuint index, const GLfloat *v) const
  1444. {
  1445. if (_glVertexAttrib1fv)
  1446. {
  1447. _glVertexAttrib1fv(index, v);
  1448. }
  1449. else
  1450. {
  1451. NotSupported( "glVertexAttrib1fv" );
  1452. }
  1453. }
  1454. void GL2Extensions::glVertexAttrib1s(GLuint index, GLshort x) const
  1455. {
  1456. if (_glVertexAttrib1s)
  1457. {
  1458. _glVertexAttrib1s(index, x);
  1459. }
  1460. else
  1461. {
  1462. NotSupported( "glVertexAttrib1s" );
  1463. }
  1464. }
  1465. void GL2Extensions::glVertexAttrib1sv(GLuint index, const GLshort *v) const
  1466. {
  1467. if (_glVertexAttrib1sv)
  1468. {
  1469. _glVertexAttrib1sv(index, v);
  1470. }
  1471. else
  1472. {
  1473. NotSupported( "glVertexAttrib1sv" );
  1474. }
  1475. }
  1476. void GL2Extensions::glVertexAttrib2d(GLuint index, GLdouble x, GLdouble y) const
  1477. {
  1478. if (_glVertexAttrib2d)
  1479. {
  1480. _glVertexAttrib2d(index, x, y);
  1481. }
  1482. else
  1483. {
  1484. NotSupported( "glVertexAttrib2d" );
  1485. }
  1486. }
  1487. void GL2Extensions::glVertexAttrib2dv(GLuint index, const GLdouble *v) const
  1488. {
  1489. if (_glVertexAttrib2dv)
  1490. {
  1491. _glVertexAttrib2dv(index, v);
  1492. }
  1493. else
  1494. {
  1495. NotSupported( "glVertexAttrib2dv" );
  1496. }
  1497. }
  1498. void GL2Extensions::glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) const
  1499. {
  1500. if (_glVertexAttrib2f)
  1501. {
  1502. _glVertexAttrib2f(index, x, y);
  1503. }
  1504. else
  1505. {
  1506. NotSupported( "glVertexAttrib2f" );
  1507. }
  1508. }
  1509. void GL2Extensions::glVertexAttrib2fv(GLuint index, const GLfloat *v) const
  1510. {
  1511. if (_glVertexAttrib2fv)
  1512. {
  1513. _glVertexAttrib2fv(index, v);
  1514. }
  1515. else
  1516. {
  1517. NotSupported( "glVertexAttrib2fv" );
  1518. }
  1519. }
  1520. void GL2Extensions::glVertexAttrib2s(GLuint index, GLshort x, GLshort y) const
  1521. {
  1522. if (_glVertexAttrib2s)
  1523. {
  1524. _glVertexAttrib2s(index, x, y);
  1525. }
  1526. else
  1527. {
  1528. NotSupported( "glVertexAttrib2s" );
  1529. }
  1530. }
  1531. void GL2Extensions::glVertexAttrib2sv(GLuint index, const GLshort *v) const
  1532. {
  1533. if (_glVertexAttrib2sv)
  1534. {
  1535. _glVertexAttrib2sv(index, v);
  1536. }
  1537. else
  1538. {
  1539. NotSupported( "glVertexAttrib2sv" );
  1540. }
  1541. }
  1542. void GL2Extensions::glVertexAttrib3d(GLuint index, GLdouble x, GLdouble y, GLdouble z) const
  1543. {
  1544. if (_glVertexAttrib3d)
  1545. {
  1546. _glVertexAttrib3d(index, x, y, z);
  1547. }
  1548. else
  1549. {
  1550. NotSupported( "glVertexAttrib3d" );
  1551. }
  1552. }
  1553. void GL2Extensions::glVertexAttrib3dv(GLuint index, const GLdouble *v) const
  1554. {
  1555. if (_glVertexAttrib3dv)
  1556. {
  1557. _glVertexAttrib3dv(index, v);
  1558. }
  1559. else
  1560. {
  1561. NotSupported( "glVertexAttrib3dv" );
  1562. }
  1563. }
  1564. void GL2Extensions::glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) const
  1565. {
  1566. if (_glVertexAttrib3f)
  1567. {
  1568. _glVertexAttrib3f(index, x, y, z);
  1569. }
  1570. else
  1571. {
  1572. NotSupported( "glVertexAttrib3f" );
  1573. }
  1574. }
  1575. void GL2Extensions::glVertexAttrib3fv(GLuint index, const GLfloat *v) const
  1576. {
  1577. if (_glVertexAttrib3fv)
  1578. {
  1579. _glVertexAttrib3fv(index, v);
  1580. }
  1581. else
  1582. {
  1583. NotSupported( "glVertexAttrib3fv" );
  1584. }
  1585. }
  1586. void GL2Extensions::glVertexAttrib3s(GLuint index, GLshort x, GLshort y, GLshort z) const
  1587. {
  1588. if (_glVertexAttrib3s)
  1589. {
  1590. _glVertexAttrib3s(index, x, y, z);
  1591. }
  1592. else
  1593. {
  1594. NotSupported( "glVertexAttrib3s" );
  1595. }
  1596. }
  1597. void GL2Extensions::glVertexAttrib3sv(GLuint index, const GLshort *v) const
  1598. {
  1599. if (_glVertexAttrib3sv)
  1600. {
  1601. _glVertexAttrib3sv(index, v);
  1602. }
  1603. else
  1604. {
  1605. NotSupported( "glVertexAttrib3sv" );
  1606. }
  1607. }
  1608. void GL2Extensions::glVertexAttrib4Nbv(GLuint index, const GLbyte *v) const
  1609. {
  1610. if (_glVertexAttrib4Nbv)
  1611. {
  1612. _glVertexAttrib4Nbv(index, v);
  1613. }
  1614. else
  1615. {
  1616. NotSupported( "glVertexAttrib4Nbv" );
  1617. }
  1618. }
  1619. void GL2Extensions::glVertexAttrib4Niv(GLuint index, const GLint *v) const
  1620. {
  1621. if (_glVertexAttrib4Niv)
  1622. {
  1623. _glVertexAttrib4Niv(index, v);
  1624. }
  1625. else
  1626. {
  1627. NotSupported( "glVertexAttrib4Niv" );
  1628. }
  1629. }
  1630. void GL2Extensions::glVertexAttrib4Nsv(GLuint index, const GLshort *v) const
  1631. {
  1632. if (_glVertexAttrib4Nsv)
  1633. {
  1634. _glVertexAttrib4Nsv(index, v);
  1635. }
  1636. else
  1637. {
  1638. NotSupported( "glVertexAttrib4Nsv" );
  1639. }
  1640. }
  1641. void GL2Extensions::glVertexAttrib4Nub(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) const
  1642. {
  1643. if (_glVertexAttrib4Nub)
  1644. {
  1645. _glVertexAttrib4Nub(index, x, y, z, w);
  1646. }
  1647. else
  1648. {
  1649. NotSupported( "glVertexAttrib4Nub" );
  1650. }
  1651. }
  1652. void GL2Extensions::glVertexAttrib4Nubv(GLuint index, const GLubyte *v) const
  1653. {
  1654. if (_glVertexAttrib4Nubv)
  1655. {
  1656. _glVertexAttrib4Nubv(index, v);
  1657. }
  1658. else
  1659. {
  1660. NotSupported( "glVertexAttrib4Nubv" );
  1661. }
  1662. }
  1663. void GL2Extensions::glVertexAttrib4Nuiv(GLuint index, const GLuint *v) const
  1664. {
  1665. if (_glVertexAttrib4Nuiv)
  1666. {
  1667. _glVertexAttrib4Nuiv(index, v);
  1668. }
  1669. else
  1670. {
  1671. NotSupported( "glVertexAttrib4Nuiv" );
  1672. }
  1673. }
  1674. void GL2Extensions::glVertexAttrib4Nusv(GLuint index, const GLushort *v) const
  1675. {
  1676. if (_glVertexAttrib4Nusv)
  1677. {
  1678. _glVertexAttrib4Nusv(index, v);
  1679. }
  1680. else
  1681. {
  1682. NotSupported( "glVertexAttrib4Nusv" );
  1683. }
  1684. }
  1685. void GL2Extensions::glVertexAttrib4bv(GLuint index, const GLbyte *v) const
  1686. {
  1687. if (_glVertexAttrib4bv)
  1688. {
  1689. _glVertexAttrib4bv(index, v);
  1690. }
  1691. else
  1692. {
  1693. NotSupported( "glVertexAttrib4bv" );
  1694. }
  1695. }
  1696. void GL2Extensions::glVertexAttrib4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) const
  1697. {
  1698. if (_glVertexAttrib4d)
  1699. {
  1700. _glVertexAttrib4d(index, x, y, z, w);
  1701. }
  1702. else
  1703. {
  1704. NotSupported( "glVertexAttrib4d" );
  1705. }
  1706. }
  1707. void GL2Extensions::glVertexAttrib4dv(GLuint index, const GLdouble *v) const
  1708. {
  1709. if (_glVertexAttrib4dv)
  1710. {
  1711. _glVertexAttrib4dv(index, v);
  1712. }
  1713. else
  1714. {
  1715. NotSupported( "glVertexAttrib4dv" );
  1716. }
  1717. }
  1718. void GL2Extensions::glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) const
  1719. {
  1720. if (_glVertexAttrib4f)
  1721. {
  1722. _glVertexAttrib4f(index, x, y, z, w);
  1723. }
  1724. else
  1725. {
  1726. NotSupported( "glVertexAttrib4f" );
  1727. }
  1728. }
  1729. void GL2Extensions::glVertexAttrib4fv(GLuint index, const GLfloat *v) const
  1730. {
  1731. if (_glVertexAttrib4fv)
  1732. {
  1733. _glVertexAttrib4fv(index, v);
  1734. }
  1735. else
  1736. {
  1737. NotSupported( "glVertexAttrib4fv" );
  1738. }
  1739. }
  1740. void GL2Extensions::glVertexAttrib4iv(GLuint index, const GLint *v) const
  1741. {
  1742. if (_glVertexAttrib4iv)
  1743. {
  1744. _glVertexAttrib4iv(index, v);
  1745. }
  1746. else
  1747. {
  1748. NotSupported( "glVertexAttrib4iv" );
  1749. }
  1750. }
  1751. void GL2Extensions::glVertexAttrib4s(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) const
  1752. {
  1753. if (_glVertexAttrib4s)
  1754. {
  1755. _glVertexAttrib4s(index, x, y, z, w);
  1756. }
  1757. else
  1758. {
  1759. NotSupported( "glVertexAttrib4s" );
  1760. }
  1761. }
  1762. void GL2Extensions::glVertexAttrib4sv(GLuint index, const GLshort *v) const
  1763. {
  1764. if (_glVertexAttrib4sv)
  1765. {
  1766. _glVertexAttrib4sv(index, v);
  1767. }
  1768. else
  1769. {
  1770. NotSupported( "glVertexAttrib4sv" );
  1771. }
  1772. }
  1773. void GL2Extensions::glVertexAttrib4ubv(GLuint index, const GLubyte *v) const
  1774. {
  1775. if (_glVertexAttrib4ubv)
  1776. {
  1777. _glVertexAttrib4ubv(index, v);
  1778. }
  1779. else
  1780. {
  1781. NotSupported( "glVertexAttrib4ubv" );
  1782. }
  1783. }
  1784. void GL2Extensions::glVertexAttrib4uiv(GLuint index, const GLuint *v) const
  1785. {
  1786. if (_glVertexAttrib4uiv)
  1787. {
  1788. _glVertexAttrib4uiv(index, v);
  1789. }
  1790. else
  1791. {
  1792. NotSupported( "glVertexAttrib4uiv" );
  1793. }
  1794. }
  1795. void GL2Extensions::glVertexAttrib4usv(GLuint index, const GLushort *v) const
  1796. {
  1797. if (_glVertexAttrib4usv)
  1798. {
  1799. _glVertexAttrib4usv(index, v);
  1800. }
  1801. else
  1802. {
  1803. NotSupported( "glVertexAttrib4usv" );
  1804. }
  1805. }
  1806. void GL2Extensions::glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) const
  1807. {
  1808. if (_glVertexAttribPointer)
  1809. {
  1810. _glVertexAttribPointer(index, size, type, normalized, stride, pointer);
  1811. }
  1812. else
  1813. {
  1814. NotSupported( "glVertexAttribPointer" );
  1815. }
  1816. }
  1817. void GL2Extensions::glUniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const
  1818. {
  1819. if (_glUniformMatrix2x3fv)
  1820. {
  1821. _glUniformMatrix2x3fv( location, count, transpose, value );
  1822. }
  1823. else
  1824. {
  1825. NotSupported( "glUniformMatrix2x3fv" );
  1826. }
  1827. }
  1828. void GL2Extensions::glUniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const
  1829. {
  1830. if (_glUniformMatrix3x2fv)
  1831. {
  1832. _glUniformMatrix3x2fv( location, count, transpose, value );
  1833. }
  1834. else
  1835. {
  1836. NotSupported( "glUniformMatrix3x2fv" );
  1837. }
  1838. }
  1839. void GL2Extensions::glUniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const
  1840. {
  1841. if (_glUniformMatrix2x4fv)
  1842. {
  1843. _glUniformMatrix2x4fv( location, count, transpose, value );
  1844. }
  1845. else
  1846. {
  1847. NotSupported( "glUniformMatrix2x4fv" );
  1848. }
  1849. }
  1850. void GL2Extensions::glUniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const
  1851. {
  1852. if (_glUniformMatrix4x2fv)
  1853. {
  1854. _glUniformMatrix4x2fv( location, count, transpose, value );
  1855. }
  1856. else
  1857. {
  1858. NotSupported( "glUniformMatrix4x2fv" );
  1859. }
  1860. }
  1861. void GL2Extensions::glUniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const
  1862. {
  1863. if (_glUniformMatrix3x4fv)
  1864. {
  1865. _glUniformMatrix3x4fv( location, count, transpose, value );
  1866. }
  1867. else
  1868. {
  1869. NotSupported( "glUniformMatrix3x4fv" );
  1870. }
  1871. }
  1872. void GL2Extensions::glUniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const
  1873. {
  1874. if (_glUniformMatrix4x3fv)
  1875. {
  1876. _glUniformMatrix4x3fv( location, count, transpose, value );
  1877. }
  1878. else
  1879. {
  1880. NotSupported( "glUniformMatrix4x3fv" );
  1881. }
  1882. }
  1883. void GL2Extensions::glProgramParameteri( GLuint program, GLenum pname, GLint value ) const
  1884. {
  1885. if (_glProgramParameteri)
  1886. {
  1887. _glProgramParameteri( program, pname, value );
  1888. }
  1889. else
  1890. {
  1891. NotSupported( "glProgramParameteri" );
  1892. }
  1893. }
  1894. void GL2Extensions::glFramebufferTexture( GLenum target, GLenum attachment, GLuint texture, GLint level ) const
  1895. {
  1896. if (_glFramebufferTexture)
  1897. {
  1898. _glFramebufferTexture( target, attachment, texture, level );
  1899. }
  1900. else
  1901. {
  1902. NotSupported( "glFramebufferTexture" );
  1903. }
  1904. }
  1905. void GL2Extensions::glFramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) const
  1906. {
  1907. if (_glFramebufferTextureLayer)
  1908. {
  1909. _glFramebufferTextureLayer( target, attachment, texture, level, layer );
  1910. }
  1911. else
  1912. {
  1913. NotSupported( "glFramebufferTextureLayer" );
  1914. }
  1915. }
  1916. void GL2Extensions::glFramebufferTextureFace( GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face ) const
  1917. {
  1918. if (_glFramebufferTextureFace)
  1919. {
  1920. _glFramebufferTextureFace( target, attachment, texture, level, face );
  1921. }
  1922. else
  1923. {
  1924. NotSupported( "glFramebufferTextureFace" );
  1925. }
  1926. }
  1927. void GL2Extensions::glPatchParameteri( GLenum pname, GLint value ) const
  1928. {
  1929. if (_glPatchParameteri)
  1930. {
  1931. _glPatchParameteri( pname, value );
  1932. }
  1933. else
  1934. {
  1935. NotSupported( "glPatchParameteri" );
  1936. }
  1937. }
  1938. void GL2Extensions::glPatchParameterfv( GLenum pname, const GLfloat* values ) const
  1939. {
  1940. if (_glPatchParameterfv)
  1941. {
  1942. _glPatchParameterfv( pname, values );
  1943. }
  1944. else
  1945. {
  1946. NotSupported( "glPatchParameterfv" );
  1947. }
  1948. }
  1949. void GL2Extensions::glGetUniformuiv( GLuint program, GLint location, GLuint* params ) const
  1950. {
  1951. if (_glGetUniformuiv)
  1952. {
  1953. _glGetUniformuiv( program, location, params );
  1954. }
  1955. else
  1956. {
  1957. NotSupported( "glGetUniformuiv" );
  1958. }
  1959. }
  1960. void GL2Extensions::glBindFragDataLocation( GLuint program, GLuint color, const GLchar* name ) const
  1961. {
  1962. if (_glBindFragDataLocation)
  1963. {
  1964. _glBindFragDataLocation( program, color, name );
  1965. }
  1966. else
  1967. {
  1968. NotSupported( "glBindFragDataLocation" );
  1969. }
  1970. }
  1971. GLint GL2Extensions::glGetFragDataLocation( GLuint program, const GLchar* name ) const
  1972. {
  1973. if (_glGetFragDataLocation)
  1974. {
  1975. return _glGetFragDataLocation( program, name );
  1976. }
  1977. else
  1978. {
  1979. NotSupported( "glGetFragDataLocation" );
  1980. return -1;
  1981. }
  1982. }
  1983. void GL2Extensions::glUniform1ui( GLint location, GLuint v0 ) const
  1984. {
  1985. if (_glUniform1ui)
  1986. {
  1987. _glUniform1ui( location, v0 );
  1988. }
  1989. else
  1990. {
  1991. NotSupported( "glUniform1ui" );
  1992. }
  1993. }
  1994. void GL2Extensions::glUniform2ui( GLint location, GLuint v0, GLuint v1 ) const
  1995. {
  1996. if (_glUniform2ui)
  1997. {
  1998. _glUniform2ui( location, v0, v1 );
  1999. }
  2000. else
  2001. {
  2002. NotSupported( "glUniform2ui" );
  2003. }
  2004. }
  2005. void GL2Extensions::glUniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) const
  2006. {
  2007. if (_glUniform3ui)
  2008. {
  2009. _glUniform3ui( location, v0, v1, v2 );
  2010. }
  2011. else
  2012. {
  2013. NotSupported( "glUniform3ui" );
  2014. }
  2015. }
  2016. void GL2Extensions::glUniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) const
  2017. {
  2018. if (_glUniform4ui)
  2019. {
  2020. _glUniform4ui( location, v0, v1, v2, v3 );
  2021. }
  2022. else
  2023. {
  2024. NotSupported( "glUniform4ui" );
  2025. }
  2026. }
  2027. void GL2Extensions::glUniform1uiv( GLint location, GLsizei count, const GLuint *value ) const
  2028. {
  2029. if (_glUniform1uiv)
  2030. {
  2031. _glUniform1uiv( location, count, value );
  2032. }
  2033. else
  2034. {
  2035. NotSupported( "glUniform1uiv" );
  2036. }
  2037. }
  2038. void GL2Extensions::glUniform2uiv( GLint location, GLsizei count, const GLuint *value ) const
  2039. {
  2040. if (_glUniform2uiv)
  2041. {
  2042. _glUniform2uiv( location, count, value );
  2043. }
  2044. else
  2045. {
  2046. NotSupported( "glUniform2uiv" );
  2047. }
  2048. }
  2049. void GL2Extensions::glUniform3uiv( GLint location, GLsizei count, const GLuint *value ) const
  2050. {
  2051. if (_glUniform3uiv)
  2052. {
  2053. _glUniform3uiv( location, count, value );
  2054. }
  2055. else
  2056. {
  2057. NotSupported( "glUniform3uiv" );
  2058. }
  2059. }
  2060. void GL2Extensions::glUniform4uiv( GLint location, GLsizei count, const GLuint *value ) const
  2061. {
  2062. if (_glUniform4uiv)
  2063. {
  2064. _glUniform4uiv( location, count, value );
  2065. }
  2066. else
  2067. {
  2068. NotSupported( "glUniform4uiv" );
  2069. }
  2070. }
  2071. // ARB_uniform_buffer_object
  2072. void GL2Extensions::glGetUniformIndices(GLuint program, GLsizei uniformCount,
  2073. const GLchar* *uniformNames,
  2074. GLuint *uniformIndices) const
  2075. {
  2076. if (_glGetUniformIndices)
  2077. {
  2078. _glGetUniformIndices(program, uniformCount, uniformNames,
  2079. uniformIndices);
  2080. }
  2081. else
  2082. {
  2083. NotSupported("glGetUniformIndices");
  2084. }
  2085. }
  2086. void GL2Extensions::glGetActiveUniformsiv(GLuint program, GLsizei uniformCount,
  2087. const GLuint *uniformIndices,
  2088. GLenum pname, GLint *params) const
  2089. {
  2090. if (_glGetActiveUniformsiv)
  2091. {
  2092. _glGetActiveUniformsiv(program, uniformCount, uniformIndices, pname,
  2093. params);
  2094. }
  2095. else
  2096. {
  2097. NotSupported("glGetActiveUniformsiv");
  2098. }
  2099. }
  2100. void GL2Extensions::glGetActiveUniformName(GLuint program, GLuint uniformIndex,
  2101. GLsizei bufSize, GLsizei *length,
  2102. GLchar *uniformName) const
  2103. {
  2104. if (_glGetActiveUniformName)
  2105. {
  2106. _glGetActiveUniformName(program, uniformIndex, bufSize, length,
  2107. uniformName);
  2108. }
  2109. else
  2110. {
  2111. NotSupported("glGetActiveUniformName");
  2112. }
  2113. }
  2114. GLuint GL2Extensions::glGetUniformBlockIndex(GLuint program,
  2115. const GLchar *uniformBlockName) const
  2116. {
  2117. if (_glGetUniformBlockIndex)
  2118. {
  2119. return _glGetUniformBlockIndex(program, uniformBlockName);
  2120. }
  2121. else
  2122. {
  2123. NotSupported("glGetUniformBlockIndex");
  2124. return GL_INVALID_INDEX;
  2125. }
  2126. }
  2127. void GL2Extensions::glGetActiveUniformBlockiv(GLuint program,
  2128. GLuint uniformBlockIndex,
  2129. GLenum pname, GLint *params) const
  2130. {
  2131. if (_glGetActiveUniformBlockiv)
  2132. {
  2133. _glGetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
  2134. }
  2135. else
  2136. {
  2137. NotSupported("glGetActiveUniformBlockiv");
  2138. }
  2139. }
  2140. void GL2Extensions::glGetActiveUniformBlockName(GLuint program,
  2141. GLuint uniformBlockIndex,
  2142. GLsizei bufSize,
  2143. GLsizei *length,
  2144. GLchar *uniformBlockName) const
  2145. {
  2146. if (_glGetActiveUniformBlockName)
  2147. {
  2148. _glGetActiveUniformBlockName(program, uniformBlockIndex, bufSize,
  2149. length, uniformBlockName);
  2150. }
  2151. else
  2152. {
  2153. NotSupported("glGetActiveUniformBlockName");
  2154. }
  2155. }
  2156. void GL2Extensions::glUniformBlockBinding(GLuint program,
  2157. GLuint uniformBlockIndex,
  2158. GLuint uniformBlockBinding) const
  2159. {
  2160. if (_glUniformBlockBinding)
  2161. {
  2162. _glUniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
  2163. }
  2164. else
  2165. {
  2166. NotSupported("glUniformBlockBinding");
  2167. }
  2168. }
  2169. //ARB_get_program_binary
  2170. void GL2Extensions::glGetProgramBinary(GLuint program,
  2171. GLsizei bufSize,
  2172. GLsizei *length,
  2173. GLenum *binaryFormat,
  2174. GLvoid *binary) const
  2175. {
  2176. if (_glGetProgramBinary)
  2177. {
  2178. _glGetProgramBinary(program, bufSize, length, binaryFormat, binary);
  2179. }
  2180. else
  2181. {
  2182. NotSupported("glGetProgramBinary");
  2183. }
  2184. }
  2185. void GL2Extensions::glProgramBinary(GLuint program,
  2186. GLenum binaryFormat,
  2187. const GLvoid *binary,
  2188. GLsizei length) const
  2189. {
  2190. if (_glProgramBinary)
  2191. {
  2192. _glProgramBinary(program, binaryFormat, binary, length);
  2193. }
  2194. else
  2195. {
  2196. NotSupported("glProgramBinary");
  2197. }
  2198. }
  2199. void GL2Extensions::glUniform1d(GLint location, GLdouble v0) const
  2200. {
  2201. if (_glUniform1d)
  2202. {
  2203. _glUniform1d(location, v0);
  2204. }
  2205. else
  2206. {
  2207. NotSupported( "glUniform1d" );
  2208. }
  2209. }
  2210. void GL2Extensions::glUniform2d(GLint location, GLdouble v0, GLdouble v1) const
  2211. {
  2212. if (_glUniform2d)
  2213. {
  2214. _glUniform2d(location, v0, v1);
  2215. }
  2216. else
  2217. {
  2218. NotSupported( "glUniform2d" );
  2219. }
  2220. }
  2221. void GL2Extensions::glUniform3d(GLint location, GLdouble v0, GLdouble v1, GLdouble v2) const
  2222. {
  2223. if (_glUniform3d)
  2224. {
  2225. _glUniform3d(location, v0, v1, v2);
  2226. }
  2227. else
  2228. {
  2229. NotSupported( "glUniform3d" );
  2230. }
  2231. }
  2232. void GL2Extensions::glUniform4d(GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3) const
  2233. {
  2234. if (_glUniform4d)
  2235. {
  2236. _glUniform4d(location, v0, v1, v2, v3);
  2237. }
  2238. else
  2239. {
  2240. NotSupported( "glUniform4d" );
  2241. }
  2242. }
  2243. void GL2Extensions::glUniform1dv(GLint location, GLsizei count, const GLdouble *value) const
  2244. {
  2245. if (_glUniform1dv)
  2246. {
  2247. _glUniform1dv(location, count, value);
  2248. }
  2249. else
  2250. {
  2251. NotSupported( "glUniform1dv" );
  2252. }
  2253. }
  2254. void GL2Extensions::glUniform2dv(GLint location, GLsizei count, const GLdouble *value) const
  2255. {
  2256. if (_glUniform2dv)
  2257. {
  2258. _glUniform2dv(location, count, value);
  2259. }
  2260. else
  2261. {
  2262. NotSupported( "glUniform2dv" );
  2263. }
  2264. }
  2265. void GL2Extensions::glUniform3dv(GLint location, GLsizei count, const GLdouble *value) const
  2266. {
  2267. if (_glUniform3dv)
  2268. {
  2269. _glUniform3dv(location, count, value);
  2270. }
  2271. else
  2272. {
  2273. NotSupported( "glUniform3dv" );
  2274. }
  2275. }
  2276. void GL2Extensions::glUniform4dv(GLint location, GLsizei count, const GLdouble *value) const
  2277. {
  2278. if (_glUniform4dv)
  2279. {
  2280. _glUniform4dv(location, count, value);
  2281. }
  2282. else
  2283. {
  2284. NotSupported( "glUniform4dv" );
  2285. }
  2286. }
  2287. void GL2Extensions::glUniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) const
  2288. {
  2289. if (_glUniformMatrix2dv)
  2290. {
  2291. _glUniformMatrix2dv(location, count, transpose, value);
  2292. }
  2293. else
  2294. {
  2295. NotSupported( "glUniformMatrix2dv" );
  2296. }
  2297. }
  2298. void GL2Extensions::glUniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) const
  2299. {
  2300. if (_glUniformMatrix3dv)
  2301. {
  2302. _glUniformMatrix3dv(location, count, transpose, value);
  2303. }
  2304. else
  2305. {
  2306. NotSupported( "glUniformMatrix3dv" );
  2307. }
  2308. }
  2309. void GL2Extensions::glUniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) const
  2310. {
  2311. if (_glUniformMatrix4dv)
  2312. {
  2313. _glUniformMatrix4dv(location, count, transpose, value);
  2314. }
  2315. else
  2316. {
  2317. NotSupported( "glUniformMatrix4dv" );
  2318. }
  2319. }
  2320. void GL2Extensions::glUniformMatrix2x3dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const
  2321. {
  2322. if (_glUniformMatrix2x3dv)
  2323. {
  2324. _glUniformMatrix2x3dv( location, count, transpose, value );
  2325. }
  2326. else
  2327. {
  2328. NotSupported( "glUniformMatrix2x3dv" );
  2329. }
  2330. }
  2331. void GL2Extensions::glUniformMatrix3x2dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const
  2332. {
  2333. if (_glUniformMatrix3x2dv)
  2334. {
  2335. _glUniformMatrix3x2dv( location, count, transpose, value );
  2336. }
  2337. else
  2338. {
  2339. NotSupported( "glUniformMatrix3x2dv" );
  2340. }
  2341. }
  2342. void GL2Extensions::glUniformMatrix2x4dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const
  2343. {
  2344. if (_glUniformMatrix2x4dv)
  2345. {
  2346. _glUniformMatrix2x4dv( location, count, transpose, value );
  2347. }
  2348. else
  2349. {
  2350. NotSupported( "glUniformMatrix2x4dv" );
  2351. }
  2352. }
  2353. void GL2Extensions::glUniformMatrix4x2dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const
  2354. {
  2355. if (_glUniformMatrix4x2dv)
  2356. {
  2357. _glUniformMatrix4x2dv( location, count, transpose, value );
  2358. }
  2359. else
  2360. {
  2361. NotSupported( "glUniformMatrix4x2dv" );
  2362. }
  2363. }
  2364. void GL2Extensions::glUniformMatrix3x4dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const
  2365. {
  2366. if (_glUniformMatrix3x4dv)
  2367. {
  2368. _glUniformMatrix3x4dv( location, count, transpose, value );
  2369. }
  2370. else
  2371. {
  2372. NotSupported( "glUniformMatrix3x4dv" );
  2373. }
  2374. }
  2375. void GL2Extensions::glUniformMatrix4x3dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const
  2376. {
  2377. if (_glUniformMatrix4x3dv)
  2378. {
  2379. _glUniformMatrix4x3dv( location, count, transpose, value );
  2380. }
  2381. else
  2382. {
  2383. NotSupported( "glUniformMatrix4x3dv" );
  2384. }
  2385. }
  2386. void GL2Extensions::glGetActiveAtomicCounterBufferiv( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params ) const
  2387. {
  2388. if (_glGetActiveAtomicCounterBufferiv)
  2389. {
  2390. _glGetActiveAtomicCounterBufferiv( program, bufferIndex, pname, params );
  2391. }
  2392. else
  2393. {
  2394. NotSupported( "glGetActiveAtomicCounterBufferiv" );
  2395. }
  2396. }
  2397. ///////////////////////////////////////////////////////////////////////////
  2398. // C++-friendly convenience methods
  2399. GLuint GL2Extensions::getCurrentProgram() const
  2400. {
  2401. if( _glVersion >= 2.0f )
  2402. {
  2403. // GLSL as GL v2.0 core functionality
  2404. GLint result = 0;
  2405. glGetIntegerv( GL_CURRENT_PROGRAM, &result );
  2406. return static_cast<GLuint>(result);
  2407. }
  2408. else if (_glGetHandleARB)
  2409. {
  2410. // fallback for GLSL as GL v1.5 ARB extension
  2411. #ifndef GL_PROGRAM_OBJECT_ARB
  2412. #define GL_PROGRAM_OBJECT_ARB 0x8B40
  2413. #endif
  2414. return _glGetHandleARB( GL_PROGRAM_OBJECT_ARB );
  2415. }
  2416. else
  2417. {
  2418. NotSupported( "getCurrentProgram" );
  2419. return 0;
  2420. }
  2421. }
  2422. bool GL2Extensions::getProgramInfoLog( GLuint program, std::string& result ) const
  2423. {
  2424. GLsizei bufLen = 0; // length of buffer to allocate
  2425. GLsizei strLen = 0; // strlen GL actually wrote to buffer
  2426. glGetProgramiv( program, GL_INFO_LOG_LENGTH, &bufLen );
  2427. if( bufLen > 1 )
  2428. {
  2429. GLchar* infoLog = new GLchar[bufLen];
  2430. glGetProgramInfoLog( program, bufLen, &strLen, infoLog );
  2431. if( strLen > 0 ) result = reinterpret_cast<char*>(infoLog);
  2432. delete [] infoLog;
  2433. }
  2434. return (strLen > 0);
  2435. }
  2436. bool GL2Extensions::getShaderInfoLog( GLuint shader, std::string& result ) const
  2437. {
  2438. GLsizei bufLen = 0; // length of buffer to allocate
  2439. GLsizei strLen = 0; // strlen GL actually wrote to buffer
  2440. glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &bufLen );
  2441. if( bufLen > 1 )
  2442. {
  2443. GLchar* infoLog = new GLchar[bufLen];
  2444. glGetShaderInfoLog( shader, bufLen, &strLen, infoLog );
  2445. if( strLen > 0 ) result = reinterpret_cast<char*>(infoLog);
  2446. delete [] infoLog;
  2447. }
  2448. return (strLen > 0);
  2449. }
  2450. bool GL2Extensions::getAttribLocation( const char* attribName, GLuint& location ) const
  2451. {
  2452. // is there an active GLSL program?
  2453. GLuint program = getCurrentProgram();
  2454. if( glIsProgram(program) == GL_FALSE ) return false;
  2455. // has that program been successfully linked?
  2456. GLint linked = GL_FALSE;
  2457. glGetProgramiv( program, GL_LINK_STATUS, &linked );
  2458. if( linked == GL_FALSE ) return false;
  2459. // is there such a named attribute?
  2460. GLint loc = glGetAttribLocation( program, reinterpret_cast<const GLchar*>(attribName) );
  2461. if( loc < 0 ) return false;
  2462. location = loc;
  2463. return true;
  2464. }
  2465. bool GL2Extensions::getFragDataLocation( const char* fragDataName, GLuint& location ) const
  2466. {
  2467. // is there an active GLSL program?
  2468. GLuint program = getCurrentProgram();
  2469. if( glIsProgram(program) == GL_FALSE ) return false;
  2470. // has that program been successfully linked?
  2471. GLint linked = GL_FALSE;
  2472. glGetProgramiv( program, GL_LINK_STATUS, &linked );
  2473. if( linked == GL_FALSE ) return false;
  2474. // check if supported
  2475. if (_glGetFragDataLocation == NULL) return false;
  2476. // is there such a named attribute?
  2477. GLint loc = glGetFragDataLocation( program, reinterpret_cast<const GLchar*>(fragDataName) );
  2478. if( loc < 0 ) return false;
  2479. location = loc;
  2480. return true;
  2481. }