1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_GLEXTENSIONS
15#define OSG_GLEXTENSIONS 1
16
17#include <osg/Export>
18#include <osg/GLDefines>
19
20#include <stdlib.h>
21#include <string.h>
22#include <string>
23
24
25namespace osg {
26
27/** Return floating-point OpenGL version number.
28  * Note: Must only be called within a valid OpenGL context,
29  * undefined behavior may occur otherwise.
30*/
31extern OSG_EXPORT float getGLVersionNumber();
32
33/** Return true if "extension" is contained in "extensionString".
34*/
35extern OSG_EXPORT bool isExtensionInExtensionString(const char *extension, const char *extensionString);
36
37/** Return true if OpenGL "extension" is supported.
38  * Note: Must only be called within a valid OpenGL context,
39  * undefined behavior may occur otherwise.
40*/
41extern OSG_EXPORT bool isGLExtensionSupported(unsigned int contextID, const char *extension);
42
43/** Return true if OpenGL "extension" or minimum OpenGL version number is supported.
44  * Note: Must only be called within a valid OpenGL context,
45  * undefined behavior may occur otherwise.
46*/
47extern OSG_EXPORT bool isGLExtensionOrVersionSupported(unsigned int contextID, const char *extension, float requiredGlVersion);
48
49/** Return the address of the specified OpenGL function.
50  * Return NULL if function not supported by OpenGL library.
51  * Note, glGLExtensionFuncPtr is declared inline so that the code
52  * is compiled locally to the calling code.  This should get by Windows'
53  * dumb implementation of having different GL function ptr's for each
54  * library when linked to it.
55*/
56extern OSG_EXPORT void* getGLExtensionFuncPtr(const char *funcName);
57
58/** Set a list of extensions to disable for different OpenGL renderers. This allows
59  * OSG applications to work around OpenGL drivers' bugs which are due to problematic extension support.
60  * The format of the string is:
61  * "GLRendererString : ExtensionName, ExtensionName; GLRenderString2 : ExtensionName;"
62  * An example of is : "SUN_XVR1000:GL_EXT_texture_filter_anisotropic"
63  * The default setting of GLExtensionDisableString is obtained from the OSG_GL_EXTENSION_DISABLE
64  * environmental variable.
65*/
66extern OSG_EXPORT void setGLExtensionDisableString(const std::string& disableString);
67
68/** Get the list of extensions that are disabled for various OpenGL renderers. */
69extern OSG_EXPORT std::string& getGLExtensionDisableString();
70
71/** Return the address of the specified OpenGL function. If not found then
72  * check a second function name, if this fails then return NULL as function is
73  * not supported by OpenGL library. This is used for checking something
74  * like glActiveTexture (which is in OGL1.3) or glActiveTextureARB.
75*/
76inline void* getGLExtensionFuncPtr(const char *funcName, const char *fallbackFuncName)
77{
78    void* ptr = getGLExtensionFuncPtr(funcName);
79    return (ptr!=0) ? ptr : getGLExtensionFuncPtr(fallbackFuncName);
80}
81
82/** Return the address of the specified OpenGL function. If not found then
83  * check a second function name, if this fails then return NULL as function is
84  * not supported by OpenGL library. This is used for checking something
85  * like glActiveTexture (which is in OGL1.3) or glActiveTextureARB.
86*/
87inline void* getGLExtensionFuncPtr(const char *funcName1, const char *funcName2, const char *funcName3)
88{
89    void* ptr = getGLExtensionFuncPtr(funcName1);
90    return (ptr!=0) ? ptr : getGLExtensionFuncPtr(funcName2, funcName3);
91}
92
93template<typename T, typename R>
94bool convertPointer(T& dest, R src)
95{
96    memcpy(&dest, &src, sizeof(src));
97    return src!=0;
98}
99
100template<typename T, typename R>
101T convertPointerType(R src)
102{
103    T dest;
104    memcpy(&dest, &src, sizeof(src));
105    return dest;
106}
107
108template<typename T>
109bool setGLExtensionFuncPtr(T& t, const char* str1)
110{
111    return convertPointer(t, osg::getGLExtensionFuncPtr(str1));
112}
113
114template<typename T>
115bool setGLExtensionFuncPtr(T& t, const char* str1, const char* str2)
116{
117    return convertPointer(t, osg::getGLExtensionFuncPtr(str1, str2));
118}
119
120template<typename T>
121bool setGLExtensionFuncPtr(T& t, const char* str1, const char* str2, const char* str3)
122{
123    return convertPointer(t, osg::getGLExtensionFuncPtr(str1, str2, str3));
124}
125
126/** Main GLExtensions class for managing OpenGL extensions per graphics context.*/
127class OSG_EXPORT GLExtensions : public osg::Referenced
128{
129    public:
130        GLExtensions(unsigned int contextID);
131
132        /** Function to call to get the extension of a specified context.
133          * If the Exentsion object for that context has not yet been created then
134          * and the 'createIfNotInitalized' flag been set to false then returns NULL.
135          * If 'createIfNotInitalized' is true then the Extensions object is
136          * automatically created.  However, in this case the extension object
137          * only be created with the graphics context associated with ContextID..*/
138        static GLExtensions* Get(unsigned int contextID,bool createIfNotInitalized);
139
140        /** allows users to override the extensions across graphics contexts.
141          * typically used when you have different extensions supported across graphics pipes
142          * but need to ensure that they all use the same low common denominator extensions.*/
143        static void Set(unsigned int contextID, GLExtensions* extensions);
144
145        // C++-friendly convenience wrapper methods
146        GLuint getCurrentProgram() const;
147        bool getProgramInfoLog( GLuint program, std::string& result ) const;
148        bool getShaderInfoLog( GLuint shader, std::string& result ) const;
149        bool getAttribLocation( const char* attribName, GLuint& slot ) const;
150        bool getFragDataLocation( const char* fragDataName, GLuint& slot) const;
151
152
153        float glVersion;
154        float glslLanguageVersion;
155
156        bool isGlslSupported;
157        bool isShaderObjectsSupported;
158        bool isVertexShaderSupported;
159        bool isFragmentShaderSupported;
160        bool isLanguage100Supported;
161        bool isGeometryShader4Supported;
162        bool areTessellationShadersSupported;
163        bool isGpuShader4Supported;
164        bool isUniformBufferObjectSupported;
165        bool isGetProgramBinarySupported;
166        bool isGpuShaderFp64Supported;
167        bool isShaderAtomicCountersSupported;
168        bool isRectangleSupported;
169        bool isCubeMapSupported;
170        bool isClipControlSupported;
171
172        void (GL_APIENTRY * glDrawBuffers)(GLsizei n, const GLenum *bufs);
173        void (GL_APIENTRY * glAttachShader)(GLuint program, GLuint shader);
174        void (GL_APIENTRY * glBindAttribLocation)(GLuint program, GLuint index, const GLchar *name);
175        void (GL_APIENTRY * glCompileShader)(GLuint shader);
176        GLuint (GL_APIENTRY * glCreateProgram)(void);
177        GLuint (GL_APIENTRY * glCreateShader)(GLenum type);
178        void (GL_APIENTRY * glDeleteProgram)(GLuint program);
179        void (GL_APIENTRY * glDeleteObjectARB)(GLuint program);
180        void (GL_APIENTRY * glDeleteShader)(GLuint shader);
181        void (GL_APIENTRY * glDetachShader)(GLuint program, GLuint shader);
182        void (GL_APIENTRY * glDisableVertexAttribArray)(GLuint index);
183        void (GL_APIENTRY * glEnableVertexAttribArray)(GLuint index);
184        void (GL_APIENTRY * glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
185        void (GL_APIENTRY * glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
186        void (GL_APIENTRY * glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
187        GLint (GL_APIENTRY * glGetAttribLocation)(GLuint program, const GLchar *name);
188        void (GL_APIENTRY * glGetProgramiv)(GLuint program, GLenum pname, GLint *params);
189        void (GL_APIENTRY * glGetObjectParameterivARB)(GLuint program, GLenum pname, GLint *params);
190        void (GL_APIENTRY * glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
191        void (GL_APIENTRY * glGetInfoLogARB)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
192        void (GL_APIENTRY * glGetShaderiv)(GLuint shader, GLenum pname, GLint *params);
193        void (GL_APIENTRY * glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
194        void (GL_APIENTRY * glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
195        GLint (GL_APIENTRY * glGetUniformLocation)(GLuint program, const GLchar *name);
196        void (GL_APIENTRY * glGetUniformfv)(GLuint program, GLint location, GLfloat *params);
197        void (GL_APIENTRY * glGetUniformiv)(GLuint program, GLint location, GLint *params);
198        void (GL_APIENTRY * glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble *params);
199        void (GL_APIENTRY * glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat *params);
200        void (GL_APIENTRY * glGetVertexAttribiv)(GLuint index, GLenum pname, GLint *params);
201        void (GL_APIENTRY * glGetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid* *pointer);
202        GLboolean (GL_APIENTRY * glIsProgram)(GLuint program);
203        GLboolean (GL_APIENTRY * glIsShader)(GLuint shader);
204        void (GL_APIENTRY * glLinkProgram)(GLuint program);
205        void (GL_APIENTRY * glShaderSource)(GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
206        void (GL_APIENTRY * glUseProgram)(GLuint program);
207        void (GL_APIENTRY * glUniform1f)(GLint location, GLfloat v0);
208        void (GL_APIENTRY * glUniform2f)(GLint location, GLfloat v0, GLfloat v1);
209        void (GL_APIENTRY * glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
210        void (GL_APIENTRY * glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
211        void (GL_APIENTRY * glUniform1i)(GLint location, GLint v0);
212        void (GL_APIENTRY * glUniform2i)(GLint location, GLint v0, GLint v1);
213        void (GL_APIENTRY * glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2);
214        void (GL_APIENTRY * glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
215        void (GL_APIENTRY * glUniform1fv)(GLint location, GLsizei count, const GLfloat *value);
216        void (GL_APIENTRY * glUniform2fv)(GLint location, GLsizei count, const GLfloat *value);
217        void (GL_APIENTRY * glUniform3fv)(GLint location, GLsizei count, const GLfloat *value);
218        void (GL_APIENTRY * glUniform4fv)(GLint location, GLsizei count, const GLfloat *value);
219        void (GL_APIENTRY * glUniform1iv)(GLint location, GLsizei count, const GLint *value);
220        void (GL_APIENTRY * glUniform2iv)(GLint location, GLsizei count, const GLint *value);
221        void (GL_APIENTRY * glUniform3iv)(GLint location, GLsizei count, const GLint *value);
222        void (GL_APIENTRY * glUniform4iv)(GLint location, GLsizei count, const GLint *value);
223        void (GL_APIENTRY * glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
224        void (GL_APIENTRY * glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
225        void (GL_APIENTRY * glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
226        void (GL_APIENTRY * glValidateProgram)(GLuint program);
227        void (GL_APIENTRY * glVertexAttrib1d)(GLuint index, GLdouble x);
228        void (GL_APIENTRY * glVertexAttrib1dv)(GLuint index, const GLdouble *v);
229        void (GL_APIENTRY * glVertexAttrib1f)(GLuint index, GLfloat x);
230        void (GL_APIENTRY * glVertexAttrib1fv)(GLuint index, const GLfloat *v);
231        void (GL_APIENTRY * glVertexAttrib1s)(GLuint index, GLshort x);
232        void (GL_APIENTRY * glVertexAttrib1sv)(GLuint index, const GLshort *v);
233        void (GL_APIENTRY * glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y);
234        void (GL_APIENTRY * glVertexAttrib2dv)(GLuint index, const GLdouble *v);
235        void (GL_APIENTRY * glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y);
236        void (GL_APIENTRY * glVertexAttrib2fv)(GLuint index, const GLfloat *v);
237        void (GL_APIENTRY * glVertexAttrib2s)(GLuint index, GLshort x, GLshort y);
238        void (GL_APIENTRY * glVertexAttrib2sv)(GLuint index, const GLshort *v);
239        void (GL_APIENTRY * glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
240        void (GL_APIENTRY * glVertexAttrib3dv)(GLuint index, const GLdouble *v);
241        void (GL_APIENTRY * glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
242        void (GL_APIENTRY * glVertexAttrib3fv)(GLuint index, const GLfloat *v);
243        void (GL_APIENTRY * glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z);
244        void (GL_APIENTRY * glVertexAttrib3sv)(GLuint index, const GLshort *v);
245        void (GL_APIENTRY * glVertexAttrib4Nbv)(GLuint index, const GLbyte *v);
246        void (GL_APIENTRY * glVertexAttrib4Niv)(GLuint index, const GLint *v);
247        void (GL_APIENTRY * glVertexAttrib4Nsv)(GLuint index, const GLshort *v);
248        void (GL_APIENTRY * glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
249        void (GL_APIENTRY * glVertexAttrib4Nubv)(GLuint index, const GLubyte *v);
250        void (GL_APIENTRY * glVertexAttrib4Nuiv)(GLuint index, const GLuint *v);
251        void (GL_APIENTRY * glVertexAttrib4Nusv)(GLuint index, const GLushort *v);
252        void (GL_APIENTRY * glVertexAttrib4bv)(GLuint index, const GLbyte *v);
253        void (GL_APIENTRY * glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
254        void (GL_APIENTRY * glVertexAttrib4dv)(GLuint index, const GLdouble *v);
255        void (GL_APIENTRY * glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
256        void (GL_APIENTRY * glVertexAttrib4fv)(GLuint index, const GLfloat *v);
257        void (GL_APIENTRY * glVertexAttrib4iv)(GLuint index, const GLint *v);
258        void (GL_APIENTRY * glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
259        void (GL_APIENTRY * glVertexAttrib4sv)(GLuint index, const GLshort *v);
260        void (GL_APIENTRY * glVertexAttrib4ubv)(GLuint index, const GLubyte *v);
261        void (GL_APIENTRY * glVertexAttrib4uiv)(GLuint index, const GLuint *v);
262        void (GL_APIENTRY * glVertexAttrib4usv)(GLuint index, const GLushort *v);
263        void (GL_APIENTRY * glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
264        void (GL_APIENTRY * glVertexAttribDivisor)(GLuint index, GLuint divisor);
265        void (GL_APIENTRY * glUniformMatrix2x3fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
266        void (GL_APIENTRY * glUniformMatrix3x2fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
267        void (GL_APIENTRY * glUniformMatrix2x4fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
268        void (GL_APIENTRY * glUniformMatrix4x2fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
269        void (GL_APIENTRY * glUniformMatrix3x4fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
270        void (GL_APIENTRY * glUniformMatrix4x3fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
271        void (GL_APIENTRY * glClipControl)( GLenum origin, GLenum depthMode );
272        void (GL_APIENTRY * glProgramParameteri)( GLuint program, GLenum pname, GLint value );
273        void (GL_APIENTRY * glPatchParameteri)( GLenum pname, GLint value );
274        void (GL_APIENTRY * glPatchParameterfv)( GLenum pname, const GLfloat* values );
275        void (GL_APIENTRY * glGetUniformuiv)( GLuint program, GLint location, GLuint* params );
276        void (GL_APIENTRY * glBindFragDataLocation)( GLuint program, GLuint color, const GLchar* name );
277        GLint (GL_APIENTRY * glGetFragDataLocation)( GLuint program, const GLchar* name );
278        void (GL_APIENTRY * glUniform1ui)( GLint location, GLuint v0 );
279        void (GL_APIENTRY * glUniform2ui)( GLint location, GLuint v0, GLuint v1 );
280        void (GL_APIENTRY * glUniform3ui)( GLint location, GLuint v0, GLuint v1, GLuint v2 );
281        void (GL_APIENTRY * glUniform4ui)( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 );
282        void (GL_APIENTRY * glUniform1uiv)( GLint location, GLsizei count, const GLuint *value );
283        void (GL_APIENTRY * glUniform2uiv)( GLint location, GLsizei count, const GLuint *value );
284        void (GL_APIENTRY * glUniform3uiv)( GLint location, GLsizei count, const GLuint *value );
285        void (GL_APIENTRY * glUniform4uiv)( GLint location, GLsizei count, const GLuint *value );
286        GLuint (GL_APIENTRY * glGetHandleARB) (GLenum pname);
287        void (GL_APIENTRY * glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices);
288        void (GL_APIENTRY * glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
289        void (GL_APIENTRY * glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
290        GLuint (GL_APIENTRY * glGetUniformBlockIndex)(GLuint program, const GLchar *uniformBlockName);
291        void (GL_APIENTRY * glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
292        void (GL_APIENTRY * glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
293        void (GL_APIENTRY * glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
294        void (GL_APIENTRY * glGetProgramBinary)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
295        void (GL_APIENTRY * glProgramBinary)(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
296        void (GL_APIENTRY * glUniform1d)(GLint location, GLdouble v0);
297        void (GL_APIENTRY * glUniform2d)(GLint location, GLdouble v0, GLdouble v1);
298        void (GL_APIENTRY * glUniform3d)(GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
299        void (GL_APIENTRY * glUniform4d)(GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
300        void (GL_APIENTRY * glUniform1dv)(GLint location, GLsizei count, const GLdouble *value);
301        void (GL_APIENTRY * glUniform2dv)(GLint location, GLsizei count, const GLdouble *value);
302        void (GL_APIENTRY * glUniform3dv)(GLint location, GLsizei count, const GLdouble *value);
303        void (GL_APIENTRY * glUniform4dv)(GLint location, GLsizei count, const GLdouble *value);
304        void (GL_APIENTRY * glUniformMatrix2dv)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
305        void (GL_APIENTRY * glUniformMatrix3dv)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
306        void (GL_APIENTRY * glUniformMatrix4dv)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
307        void (GL_APIENTRY * glUniformMatrix2x3dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
308        void (GL_APIENTRY * glUniformMatrix3x2dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
309        void (GL_APIENTRY * glUniformMatrix2x4dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
310        void (GL_APIENTRY * glUniformMatrix4x2dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
311        void (GL_APIENTRY * glUniformMatrix3x4dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
312        void (GL_APIENTRY * glUniformMatrix4x3dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
313        void (GL_APIENTRY * glGetActiveAtomicCounterBufferiv)( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params );
314        void (GL_APIENTRY * glDispatchCompute)( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ );
315
316        // Buffer Object extensions
317        bool isBufferObjectSupported;
318        bool isPBOSupported;
319        bool isTBOSupported;
320        bool isVAOSupported;
321        bool isTransformFeedbackSupported;
322
323        void (GL_APIENTRY * glGenBuffers) (GLsizei n, GLuint *buffers);
324        void (GL_APIENTRY * glBindBuffer) (GLenum target, GLuint buffer);
325        void (GL_APIENTRY * glBufferData) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
326        void (GL_APIENTRY * glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
327        void (GL_APIENTRY * glDeleteBuffers) (GLsizei n, const GLuint *buffers);
328        GLboolean (GL_APIENTRY * glIsBuffer) (GLuint buffer);
329        void (GL_APIENTRY * glGetBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
330        GLvoid* (GL_APIENTRY * glMapBuffer) (GLenum target, GLenum access);
331        GLvoid* (GL_APIENTRY * glMapBufferRange)(GLenum target,  GLintptr offset,  GLsizeiptr length,  GLbitfield access);
332        GLboolean (GL_APIENTRY * glUnmapBuffer) (GLenum target);
333        void (GL_APIENTRY * glGetBufferParameteriv) (GLenum target, GLenum pname, GLint *params);
334        void (GL_APIENTRY * glGetBufferPointerv) (GLenum target, GLenum pname, GLvoid* *params);
335        void (GL_APIENTRY * glBindBufferRange) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
336        void (GL_APIENTRY * glBindBufferBase) (GLenum target, GLuint index, GLuint buffer);
337        void (GL_APIENTRY * glTexBuffer) (GLenum target, GLenum internalFormat, GLuint buffer);
338
339        void (GL_APIENTRY * glMemoryBarrier)( GLbitfield barriers );
340
341        // BlendFunc extensions
342        bool                isBlendFuncSeparateSupported;
343        void (GL_APIENTRY * glBlendFuncSeparate) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ;
344
345        void (GL_APIENTRY * glBlendFunci) (GLuint buf, GLenum src, GLenum dst);
346        void (GL_APIENTRY * glBlendFuncSeparatei) (GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ;
347
348
349        // Vertex Array extensions
350        bool isSecondaryColorSupported;
351        bool isFogCoordSupported;
352        bool isMultiTexSupported;
353        bool isOcclusionQuerySupported;
354        bool isARBOcclusionQuerySupported;
355        bool isTimerQuerySupported;
356        bool isARBTimerQuerySupported;
357
358        void (GL_APIENTRY * glSecondaryColor3ubv) (const GLubyte* coord);
359        void (GL_APIENTRY * glSecondaryColor3fv) (const GLfloat* coord);
360
361        void (GL_APIENTRY * glFogCoordfv) (const GLfloat* coord);
362
363        void (GL_APIENTRY * glMultiTexCoord1f) (GLenum target,GLfloat coord);
364        void (GL_APIENTRY * glMultiTexCoord1fv) (GLenum target,const GLfloat* coord);
365        void (GL_APIENTRY * glMultiTexCoord2fv) (GLenum target,const GLfloat* coord);
366        void (GL_APIENTRY * glMultiTexCoord3fv) (GLenum target,const GLfloat* coord);
367        void (GL_APIENTRY * glMultiTexCoord4fv) (GLenum target,const GLfloat* coord);
368
369        void (GL_APIENTRY * glMultiTexCoord1d) (GLenum target,GLdouble coord);
370        void (GL_APIENTRY * glMultiTexCoord1dv) (GLenum target,const GLdouble* coord);
371        void (GL_APIENTRY * glMultiTexCoord2dv) (GLenum target,const GLdouble* coord);
372        void (GL_APIENTRY * glMultiTexCoord3dv) (GLenum target,const GLdouble* coord);
373        void (GL_APIENTRY * glMultiTexCoord4dv) (GLenum target,const GLdouble* coord);
374
375        // Occlusion Query extensions
376        void (GL_APIENTRY * glGenOcclusionQueries) ( GLsizei n, GLuint *ids );
377        void (GL_APIENTRY * glDeleteOcclusionQueries) ( GLsizei n, const GLuint *ids );
378        GLboolean (GL_APIENTRY * glIsOcclusionQuery) ( GLuint id );
379        void (GL_APIENTRY * glBeginOcclusionQuery) ( GLuint id );
380        void (GL_APIENTRY * glEndOcclusionQuery) ();
381        void (GL_APIENTRY * glGetOcclusionQueryiv) ( GLuint id, GLenum pname, GLint *params );
382        void (GL_APIENTRY * glGetOcclusionQueryuiv) ( GLuint id, GLenum pname, GLuint *params );
383
384        void (GL_APIENTRY * glGetQueryiv) (GLenum target, GLenum pname, GLint *params);
385        void (GL_APIENTRY * glGenQueries) (GLsizei n, GLuint *ids);
386        void (GL_APIENTRY * glBeginQuery) (GLenum target, GLuint id);
387        void (GL_APIENTRY * glEndQuery) (GLenum target);
388        void (GL_APIENTRY * glQueryCounter) (GLuint id, GLenum target);
389        GLboolean (GL_APIENTRY * glIsQuery) (GLuint id);
390        void (GL_APIENTRY * glDeleteQueries) (GLsizei n, const GLuint *ids);
391        void (GL_APIENTRY * glGetQueryObjectiv) (GLuint id, GLenum pname, GLint *params);
392        void (GL_APIENTRY * glGetQueryObjectuiv) (GLuint id, GLenum pname, GLuint *params);
393        void (GL_APIENTRY * glGetQueryObjectui64v) (GLuint id, GLenum pname, GLuint64 *params);
394        void (GL_APIENTRY * glGetInteger64v) (GLenum pname, GLint64 *params);
395
396
397        // SampleMaski functionality
398        bool isOpenGL32upported;
399        bool isTextureMultisampleSupported;
400        bool isSampleMaskiSupported;
401
402        void (GL_APIENTRY * glSampleMaski) (GLuint maskNumber, GLbitfield mask);
403
404        // Vertex/Fragment Programs
405        bool isVertexProgramSupported;
406        bool isFragmentProgramSupported;
407
408        void (GL_APIENTRY * glBindProgram) (GLenum target, GLuint id);
409        void (GL_APIENTRY * glGenPrograms) (GLsizei n, GLuint *programs);
410        void (GL_APIENTRY * glDeletePrograms) (GLsizei n, GLuint *programs);
411        void (GL_APIENTRY * glProgramString) (GLenum target, GLenum format, GLsizei len, const void *string);
412        void (GL_APIENTRY * glProgramLocalParameter4fv) (GLenum target, GLuint index, const GLfloat *params);
413
414
415        // Texture Extensions
416        bool isMultiTexturingSupported;
417        bool isTextureFilterAnisotropicSupported;
418        bool isTextureSwizzleSupported;
419        bool isTextureCompressionARBSupported;
420        bool isTextureCompressionS3TCSupported;
421        bool isTextureCompressionPVRTC2BPPSupported;
422        bool isTextureCompressionPVRTC4BPPSupported;
423        bool isTextureCompressionETCSupported;
424        bool isTextureCompressionETC2Supported;
425        bool isTextureCompressionRGTCSupported;
426        bool isTextureCompressionPVRTCSupported;
427        bool isTextureMirroredRepeatSupported;
428        bool isTextureEdgeClampSupported;
429        bool isTextureBorderClampSupported;
430        bool isGenerateMipMapSupported;
431        bool preferGenerateMipmapSGISForPowerOfTwo;
432        bool isTextureMultisampledSupported;
433        bool isShadowSupported;
434        bool isShadowAmbientSupported;
435        bool isTextureMaxLevelSupported;
436        GLint maxTextureSize;
437        bool _isTextureStorageEnabled;
438        bool isClientStorageSupported;
439        bool isTextureIntegerEXTSupported;
440        bool isTextureStorageEnabled;
441
442        bool isTexStorage2DSupported() const { return glTexStorage2D != 0; }
443        bool isCompressedTexImage2DSupported() const { return glCompressedTexImage2D!=0; }
444        bool isCompressedTexSubImage2DSupported() const { return glCompressedTexSubImage2D!=0; }
445        bool isBindImageTextureSupported() const { return glBindImageTexture!=0; }
446        bool isNonPowerOfTwoTextureMipMappedSupported;
447        bool isNonPowerOfTwoTextureNonMipMappedSupported;
448        bool isNonPowerOfTwoTextureSupported(GLenum filter) const
449        {
450            return (filter==GL_LINEAR || filter==GL_NEAREST) ?
451                    isNonPowerOfTwoTextureNonMipMappedSupported :
452                    isNonPowerOfTwoTextureMipMappedSupported;
453        }
454
455        void (GL_APIENTRY * glTexStorage2D) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
456        void (GL_APIENTRY * glCompressedTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
457        void (GL_APIENTRY * glCompressedTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
458        void (GL_APIENTRY * glGetCompressedTexImage) (GLenum target, GLint level, GLvoid *data);
459        void (GL_APIENTRY * glTexImage2DMultisample) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
460        void (GL_APIENTRY * glTexParameterIiv) (GLenum target, GLenum pname, const GLint* data);
461        void (GL_APIENTRY * glTexParameterIuiv) (GLenum target, GLenum pname, const GLuint* data);
462        void (GL_APIENTRY * glBindImageTexture) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
463
464        // Texture3D extensions
465        bool isTexture3DSupported;
466        bool isTexture3DFast;
467        GLint maxTexture3DSize;
468        bool isCompressedTexImage3DSupported() const { return glCompressedTexImage3D!=0; }
469        bool isCompressedTexSubImage3DSupported() const { return glCompressedTexSubImage3D!=0; }
470
471        void (GL_APIENTRY * glTexImage3D) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
472        void (GL_APIENTRY * glTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
473        void (GL_APIENTRY * glCopyTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
474        void (GL_APIENTRY * glCompressedTexImage3D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
475        void (GL_APIENTRY * glCompressedTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data );
476
477        // Texture2DArray extensions
478        bool isTexture2DArraySupported;
479        GLint maxLayerCount;
480        GLint max2DSize;
481
482
483        // Blending
484        bool isBlendColorSupported;
485        bool isBlendEquationSupported;
486        bool isBlendEquationSeparateSupported;
487        bool isSGIXMinMaxSupported;
488        bool isLogicOpSupported;
489
490        void (GL_APIENTRY * glBlendColor) (GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha);
491        void (GL_APIENTRY * glBlendEquation)(GLenum mode);
492        void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
493        void (GL_APIENTRY * glBlendEquationi)(GLuint buf,  GLenum mode);
494        void (GL_APIENTRY * glBlendEquationSeparatei)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
495
496
497        // glEnablei/glDisabeli
498        void (GL_APIENTRY * glEnablei) (GLenum capability, GLuint buf);
499        void (GL_APIENTRY * glDisablei) (GLenum capability, GLuint buf);
500
501
502        // Stencil
503        bool isStencilWrapSupported;
504        bool isStencilTwoSidedSupported;
505        bool isOpenGL20Supported;
506        bool isSeparateStencilSupported;
507
508        void (GL_APIENTRY * glActiveStencilFace) (GLenum face);
509        void (GL_APIENTRY * glStencilOpSeparate) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
510        void (GL_APIENTRY * glStencilMaskSeparate) (GLenum face, GLuint mask);
511        void (GL_APIENTRY * glStencilFuncSeparate) (GLenum face, GLenum func, GLint ref, GLuint mask);
512        void (GL_APIENTRY * glStencilFuncSeparateATI) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
513
514
515        // ColorMask
516        void (GL_APIENTRY * glColorMaski)(GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
517
518
519        // ClampColor
520        bool isClampColorSupported;
521        void (GL_APIENTRY * glClampColor) (GLenum target, GLenum mode);
522
523
524        // PrimitiveRestartIndex
525        void (GL_APIENTRY * glPrimitiveRestartIndex) ( GLuint index );
526
527
528        // Mutlisample
529        bool isMultisampleSupported;
530        bool isMultisampleFilterHintSupported;
531
532        void (GL_APIENTRY * glSampleCoverage) (GLclampf value, GLboolean invert);
533
534
535        // Point
536        bool isPointParametersSupported;
537        bool isPointSpriteSupported;
538        bool isPointSpriteCoordOriginSupported;
539
540        void (GL_APIENTRY * glPointParameteri) (GLenum pname, GLint param);
541        void (GL_APIENTRY * glPointParameterf) (GLenum pname, GLfloat param);
542        void (GL_APIENTRY * glPointParameterfv) (GLenum pname, const GLfloat *params);
543
544
545        // FrameBuferObject
546        bool isFrameBufferObjectSupported;
547        bool isPackedDepthStencilSupported;
548        bool isRenderbufferMultisampleSupported() const { return glRenderbufferStorageMultisample != 0; }
549        bool isRenderbufferMultisampleCoverageSupported() const { return glRenderbufferStorageMultisampleCoverageNV != 0; }
550
551        void (GL_APIENTRY * glBindRenderbuffer) (GLenum, GLuint);
552        void (GL_APIENTRY * glDeleteRenderbuffers) (GLsizei n, const GLuint *renderbuffers);
553        void (GL_APIENTRY * glGenRenderbuffers) (GLsizei, GLuint *);
554        void (GL_APIENTRY * glRenderbufferStorage) (GLenum, GLenum, GLsizei, GLsizei);
555        void (GL_APIENTRY * glRenderbufferStorageMultisample) (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
556        void (GL_APIENTRY * glRenderbufferStorageMultisampleCoverageNV) (GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei);
557        void (GL_APIENTRY * glBindFramebuffer) (GLenum, GLuint);
558        void (GL_APIENTRY * glDeleteFramebuffers) (GLsizei n, const GLuint *framebuffers);
559        void (GL_APIENTRY * glGenFramebuffers) (GLsizei, GLuint *);
560        GLenum (GL_APIENTRY * glCheckFramebufferStatus) (GLenum);
561
562        void (GL_APIENTRY * glFramebufferTexture1D) (GLenum, GLenum, GLenum, GLuint, GLint);
563        void (GL_APIENTRY * glFramebufferTexture2D) (GLenum, GLenum, GLenum, GLuint, GLint);
564        void (GL_APIENTRY * glFramebufferTexture3D) (GLenum, GLenum, GLenum, GLuint, GLint, GLint);
565        void (GL_APIENTRY * glFramebufferTexture) (GLenum, GLenum, GLint, GLint);
566        void (GL_APIENTRY * glFramebufferTextureLayer) (GLenum, GLenum, GLuint, GLint, GLint);
567        void (GL_APIENTRY * glFramebufferTextureFace)( GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face );
568        void (GL_APIENTRY * glFramebufferRenderbuffer) (GLenum, GLenum, GLenum, GLuint);
569
570        void (GL_APIENTRY * glGenerateMipmap) (GLenum);
571        void (GL_APIENTRY * glBlitFramebuffer) (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
572        void (GL_APIENTRY * glGetRenderbufferParameteriv) (GLenum, GLenum, GLint*);
573
574
575        // Sync
576        GLsync (GL_APIENTRY * glFenceSync) (GLenum condition, GLbitfield flags);
577        GLboolean (GL_APIENTRY * glIsSync) (GLsync sync);
578        void (GL_APIENTRY * glDeleteSync) (GLsync sync);
579        GLenum (GL_APIENTRY * glClientWaitSync) (GLsync sync, GLbitfield flags, GLuint64 timeout);
580        void (GL_APIENTRY * glWaitSync) (GLsync sync, GLbitfield flags, GLuint64 timeout);
581        void (GL_APIENTRY * glGetSynciv) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
582
583
584        // Transform feedback
585        void (GL_APIENTRY * glBeginTransformFeedback) (GLenum primitiveMode);
586        void (GL_APIENTRY * glEndTransformFeedback) (void);
587        void (GL_APIENTRY * glTransformFeedbackVaryings) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);
588        void (GL_APIENTRY * glGetTransformFeedbackVarying) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
589        void (GL_APIENTRY * glBindTransformFeedback) (GLenum target, GLuint id);
590        void (GL_APIENTRY * glDeleteTransformFeedbacks) (GLsizei n, const GLuint *ids);
591        void (GL_APIENTRY * glGenTransformFeedbacks) (GLsizei n, GLuint *ids);
592        GLboolean (GL_APIENTRY * glIsTransformFeedback) (GLuint id);
593        void (GL_APIENTRY * glPauseTransformFeedback) (void);
594        void (GL_APIENTRY * glResumeTransformFeedback) (void);
595        void (GL_APIENTRY * glDrawTransformFeedback) (GLenum mode, GLuint id);
596        void (GL_APIENTRY * glDrawTransformFeedbackStream) (GLenum mode, GLuint id, GLuint stream);
597        void (GL_APIENTRY * glDrawTransformFeedbackInstanced) (GLenum mode, GLuint id, GLsizei instancecount);
598        void (GL_APIENTRY * glDrawTransformFeedbackStreamInstanced) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);
599        void (GL_APIENTRY * glCreateTransformFeedbacks) (GLsizei n, GLuint *ids);
600        void (GL_APIENTRY * glTransformFeedbackBufferBase) (GLuint xfb, GLuint index, GLuint buffer);
601        void (GL_APIENTRY * glTransformFeedbackBufferRange) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size);
602        void (GL_APIENTRY * glGetTransformFeedbackiv) (GLuint xfb, GLenum pname, GLint *param);
603        void (GL_APIENTRY * glGetTransformFeedbacki_v) (GLuint xfb, GLenum pname, GLuint index, GLint *param);
604        void (GL_APIENTRY * glGetTransformFeedbacki64_v) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param);
605
606        // Vertex Array Object
607        void (GL_APIENTRY * glDeleteVertexArrays) (GLsizei size,const GLuint *handles);
608        void (GL_APIENTRY * glGenVertexArrays) (GLsizei size, GLuint *handles);
609        GLboolean (GL_APIENTRY * glIsVertexArray) (GLuint handle);
610        void (GL_APIENTRY * glBindVertexArray) (GLuint handle);
611
612};
613
614
615}
616
617#endif
618