root/OpenSceneGraph/trunk/src/osg/GL2Extensions.cpp @ 13041

Revision 13041, 69.3 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

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