]> git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/qgl.cpp
Partial OSX support
[xonotic/netradiant.git] / radiant / qgl.cpp
1 /*
2    Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22
23 #include "qgl.h"
24
25 #include "debugging/debugging.h"
26
27 #include <stdio.h>
28 #include <cstdlib>
29 #include <string.h>
30
31 #if defined( _WIN32 )
32 #define WINGDIAPI __declspec( dllimport )
33 #define APIENTRY __stdcall
34 #endif
35
36 #include <GL/gl.h>
37
38 #if defined( _WIN32 )
39 #undef WINGDIAPI
40 #undef APIENTRY
41 #endif
42
43 #include "igl.h"
44
45
46
47
48 #if defined( _WIN32 )
49
50 #include <wtypes.h>
51
52 PROC ( WINAPI * qwglGetProcAddress )( LPCSTR );
53
54 #elif defined ( XWINDOWS )
55
56 #include <GL/glx.h>
57 #include <dlfcn.h>
58
59 Bool ( *qglXQueryExtension )( Display *dpy, int *errorb, int *event );
60 void*        ( *qglXGetProcAddressARB )( const GLubyte * procName );
61 typedef void* ( *glXGetProcAddressARBProc )( const GLubyte *procName );
62
63 #else
64 #error "unsupported platform"
65 #endif
66
67
68 void QGL_Shutdown( OpenGLBinding& table ){
69         globalOutputStream() << "Shutting down OpenGL module...";
70
71 #if defined( WIN32 )
72         qwglGetProcAddress           = 0;
73 #elif defined( XWINDOWS )
74         qglXQueryExtension           = glXQueryExtension;
75         qglXGetProcAddressARB        = 0;
76 #else
77 #error "unsupported platform"
78 #endif
79
80         globalOutputStream() << "Done.\n";
81 }
82
83
84 typedef struct glu_error_struct
85 {
86         GLenum errnum;
87         const char *errstr;
88 } GLU_ERROR_STRUCT;
89
90 GLU_ERROR_STRUCT glu_errlist[] = {
91         {GL_NO_ERROR, "GL_NO_ERROR - no error"},
92         {GL_INVALID_ENUM, "GL_INVALID_ENUM - An unacceptable value is specified for an enumerated argument."},
93         {GL_INVALID_VALUE, "GL_INVALID_VALUE - A numeric argument is out of range."},
94         {GL_INVALID_OPERATION, "GL_INVALID_OPERATION - The specified operation is not allowed in the current state."},
95         {GL_STACK_OVERFLOW, "GL_STACK_OVERFLOW - Function would cause a stack overflow."},
96         {GL_STACK_UNDERFLOW, "GL_STACK_UNDERFLOW - Function would cause a stack underflow."},
97         {GL_OUT_OF_MEMORY, "GL_OUT_OF_MEMORY - There is not enough memory left to execute the function."},
98         {0, 0}
99 };
100
101 const GLubyte* qgluErrorString( GLenum errCode ){
102         int search = 0;
103         for ( search = 0; glu_errlist[search].errstr; search++ )
104         {
105                 if ( errCode == glu_errlist[search].errnum ) {
106                         return (const GLubyte *)glu_errlist[search].errstr;
107                 }
108         } //end for
109         return (const GLubyte *)"Unknown error";
110 }
111
112
113 void glInvalidFunction(){
114         ERROR_MESSAGE( "calling an invalid OpenGL function" );
115 }
116
117 #define EXTENSIONS_ENABLED 1
118
119 bool QGL_ExtensionSupported( const char* extension ){
120 #if EXTENSIONS_ENABLED
121         const GLubyte *extensions = 0;
122         const GLubyte *start;
123         GLubyte *where, *terminator;
124
125         // Extension names should not have spaces.
126         where = (GLubyte *) strchr( extension, ' ' );
127         if ( where || *extension == '\0' ) {
128                 return false;
129         }
130
131         extensions = GlobalOpenGL().m_glGetString( GL_EXTENSIONS );
132 #ifndef __APPLE__
133         if ( !extensions ) {
134                 return false;
135         }
136 #endif
137
138         // It takes a bit of care to be fool-proof about parsing the
139         // OpenGL extensions string. Don't be fooled by sub-strings, etc.
140         for ( start = extensions; ; )
141         {
142                 where = (GLubyte *) strstr( (const char *) start, extension );
143                 if ( !where ) {
144                         break;
145                 }
146
147                 terminator = where + strlen( extension );
148                 if ( where == start || *( where - 1 ) == ' ' ) {
149                         if ( *terminator == ' ' || *terminator == '\0' ) {
150                                 return true;
151                         }
152                 }
153
154                 start = terminator;
155         }
156 #endif
157
158         return false;
159 }
160
161 typedef int ( QGL_DLLEXPORT * QGLFunctionPointer )();
162
163 QGLFunctionPointer QGL_getExtensionFunc( const char* symbol ){
164 #if defined( XWINDOWS )
165         //ASSERT_NOTNULL(qglXGetProcAddressARB);
166         if ( qglXGetProcAddressARB == 0 ) {
167                 return reinterpret_cast<QGLFunctionPointer>( glInvalidFunction );
168         }
169         else
170         {
171                 return (QGLFunctionPointer) qglXGetProcAddressARB( reinterpret_cast<const GLubyte*>( symbol ) );
172         }
173 #elif defined( WIN32 )
174         ASSERT_NOTNULL( qwglGetProcAddress );
175         return (QGLFunctionPointer) qwglGetProcAddress( symbol );
176 #else
177 #error "unsupported platform"
178 #endif
179 }
180
181
182 template<typename Func>
183 bool QGL_constructExtensionFunc( Func& func, const char* symbol ){
184         func = reinterpret_cast<Func>( QGL_getExtensionFunc( symbol ) );
185         return func != 0;
186 }
187
188 template<typename Func>
189 void QGL_invalidateExtensionFunc( Func& func ){
190         func = reinterpret_cast<Func>( glInvalidFunction );
191 }
192
193 void QGL_clear( OpenGLBinding& table ){
194         QGL_invalidateExtensionFunc( table.m_glAccum );
195         QGL_invalidateExtensionFunc( table.m_glAlphaFunc );
196         QGL_invalidateExtensionFunc( table.m_glAreTexturesResident );
197         QGL_invalidateExtensionFunc( table.m_glArrayElement );
198         QGL_invalidateExtensionFunc( table.m_glBegin );
199         QGL_invalidateExtensionFunc( table.m_glBindTexture );
200         QGL_invalidateExtensionFunc( table.m_glBitmap );
201         QGL_invalidateExtensionFunc( table.m_glBlendFunc );
202         QGL_invalidateExtensionFunc( table.m_glCallList );
203         QGL_invalidateExtensionFunc( table.m_glCallLists );
204         QGL_invalidateExtensionFunc( table.m_glClear );
205         QGL_invalidateExtensionFunc( table.m_glClearAccum );
206         QGL_invalidateExtensionFunc( table.m_glClearColor );
207         QGL_invalidateExtensionFunc( table.m_glClearDepth );
208         QGL_invalidateExtensionFunc( table.m_glClearIndex );
209         QGL_invalidateExtensionFunc( table.m_glClearStencil );
210         QGL_invalidateExtensionFunc( table.m_glClipPlane );
211         QGL_invalidateExtensionFunc( table.m_glColor3b );
212         QGL_invalidateExtensionFunc( table.m_glColor3bv );
213         QGL_invalidateExtensionFunc( table.m_glColor3d );
214         QGL_invalidateExtensionFunc( table.m_glColor3dv );
215         QGL_invalidateExtensionFunc( table.m_glColor3f );
216         QGL_invalidateExtensionFunc( table.m_glColor3fv );
217         QGL_invalidateExtensionFunc( table.m_glColor3i );
218         QGL_invalidateExtensionFunc( table.m_glColor3iv );
219         QGL_invalidateExtensionFunc( table.m_glColor3s );
220         QGL_invalidateExtensionFunc( table.m_glColor3sv );
221         QGL_invalidateExtensionFunc( table.m_glColor3ub );
222         QGL_invalidateExtensionFunc( table.m_glColor3ubv );
223         QGL_invalidateExtensionFunc( table.m_glColor3ui );
224         QGL_invalidateExtensionFunc( table.m_glColor3uiv );
225         QGL_invalidateExtensionFunc( table.m_glColor3us );
226         QGL_invalidateExtensionFunc( table.m_glColor3usv );
227         QGL_invalidateExtensionFunc( table.m_glColor4b );
228         QGL_invalidateExtensionFunc( table.m_glColor4bv );
229         QGL_invalidateExtensionFunc( table.m_glColor4d );
230         QGL_invalidateExtensionFunc( table.m_glColor4dv );
231         QGL_invalidateExtensionFunc( table.m_glColor4f );
232         QGL_invalidateExtensionFunc( table.m_glColor4fv );
233         QGL_invalidateExtensionFunc( table.m_glColor4i );
234         QGL_invalidateExtensionFunc( table.m_glColor4iv );
235         QGL_invalidateExtensionFunc( table.m_glColor4s );
236         QGL_invalidateExtensionFunc( table.m_glColor4sv );
237         QGL_invalidateExtensionFunc( table.m_glColor4ub );
238         QGL_invalidateExtensionFunc( table.m_glColor4ubv );
239         QGL_invalidateExtensionFunc( table.m_glColor4ui );
240         QGL_invalidateExtensionFunc( table.m_glColor4uiv );
241         QGL_invalidateExtensionFunc( table.m_glColor4us );
242         QGL_invalidateExtensionFunc( table.m_glColor4usv );
243         QGL_invalidateExtensionFunc( table.m_glColorMask );
244         QGL_invalidateExtensionFunc( table.m_glColorMaterial );
245         QGL_invalidateExtensionFunc( table.m_glColorPointer );
246         QGL_invalidateExtensionFunc( table.m_glCopyPixels );
247         QGL_invalidateExtensionFunc( table.m_glCopyTexImage1D );
248         QGL_invalidateExtensionFunc( table.m_glCopyTexImage2D );
249         QGL_invalidateExtensionFunc( table.m_glCopyTexSubImage1D );
250         QGL_invalidateExtensionFunc( table.m_glCopyTexSubImage2D );
251         QGL_invalidateExtensionFunc( table.m_glCullFace );
252         QGL_invalidateExtensionFunc( table.m_glDeleteLists );
253         QGL_invalidateExtensionFunc( table.m_glDeleteTextures );
254         QGL_invalidateExtensionFunc( table.m_glDepthFunc );
255         QGL_invalidateExtensionFunc( table.m_glDepthMask );
256         QGL_invalidateExtensionFunc( table.m_glDepthRange );
257         QGL_invalidateExtensionFunc( table.m_glDisable );
258         QGL_invalidateExtensionFunc( table.m_glDisableClientState );
259         QGL_invalidateExtensionFunc( table.m_glDrawArrays );
260         QGL_invalidateExtensionFunc( table.m_glDrawBuffer );
261         QGL_invalidateExtensionFunc( table.m_glDrawElements );
262         QGL_invalidateExtensionFunc( table.m_glDrawPixels );
263         QGL_invalidateExtensionFunc( table.m_glEdgeFlag );
264         QGL_invalidateExtensionFunc( table.m_glEdgeFlagPointer );
265         QGL_invalidateExtensionFunc( table.m_glEdgeFlagv );
266         QGL_invalidateExtensionFunc( table.m_glEnable );
267         QGL_invalidateExtensionFunc( table.m_glEnableClientState );
268         QGL_invalidateExtensionFunc( table.m_glEnd );
269         QGL_invalidateExtensionFunc( table.m_glEndList );
270         QGL_invalidateExtensionFunc( table.m_glEvalCoord1d );
271         QGL_invalidateExtensionFunc( table.m_glEvalCoord1dv );
272         QGL_invalidateExtensionFunc( table.m_glEvalCoord1f );
273         QGL_invalidateExtensionFunc( table.m_glEvalCoord1fv );
274         QGL_invalidateExtensionFunc( table.m_glEvalCoord2d );
275         QGL_invalidateExtensionFunc( table.m_glEvalCoord2dv );
276         QGL_invalidateExtensionFunc( table.m_glEvalCoord2f );
277         QGL_invalidateExtensionFunc( table.m_glEvalCoord2fv );
278         QGL_invalidateExtensionFunc( table.m_glEvalMesh1 );
279         QGL_invalidateExtensionFunc( table.m_glEvalMesh2 );
280         QGL_invalidateExtensionFunc( table.m_glEvalPoint1 );
281         QGL_invalidateExtensionFunc( table.m_glEvalPoint2 );
282         QGL_invalidateExtensionFunc( table.m_glFeedbackBuffer );
283         QGL_invalidateExtensionFunc( table.m_glFinish );
284         QGL_invalidateExtensionFunc( table.m_glFlush );
285         QGL_invalidateExtensionFunc( table.m_glFogf );
286         QGL_invalidateExtensionFunc( table.m_glFogfv );
287         QGL_invalidateExtensionFunc( table.m_glFogi );
288         QGL_invalidateExtensionFunc( table.m_glFogiv );
289         QGL_invalidateExtensionFunc( table.m_glFrontFace );
290         QGL_invalidateExtensionFunc( table.m_glFrustum );
291         QGL_invalidateExtensionFunc( table.m_glGenLists );
292         QGL_invalidateExtensionFunc( table.m_glGenTextures );
293         QGL_invalidateExtensionFunc( table.m_glGetBooleanv );
294         QGL_invalidateExtensionFunc( table.m_glGetClipPlane );
295         QGL_invalidateExtensionFunc( table.m_glGetDoublev );
296         QGL_invalidateExtensionFunc( table.m_glGetError );
297         QGL_invalidateExtensionFunc( table.m_glGetFloatv );
298         QGL_invalidateExtensionFunc( table.m_glGetIntegerv );
299         QGL_invalidateExtensionFunc( table.m_glGetLightfv );
300         QGL_invalidateExtensionFunc( table.m_glGetLightiv );
301         QGL_invalidateExtensionFunc( table.m_glGetMapdv );
302         QGL_invalidateExtensionFunc( table.m_glGetMapfv );
303         QGL_invalidateExtensionFunc( table.m_glGetMapiv );
304         QGL_invalidateExtensionFunc( table.m_glGetMaterialfv );
305         QGL_invalidateExtensionFunc( table.m_glGetMaterialiv );
306         QGL_invalidateExtensionFunc( table.m_glGetPixelMapfv );
307         QGL_invalidateExtensionFunc( table.m_glGetPixelMapuiv );
308         QGL_invalidateExtensionFunc( table.m_glGetPixelMapusv );
309         QGL_invalidateExtensionFunc( table.m_glGetPointerv );
310         QGL_invalidateExtensionFunc( table.m_glGetPolygonStipple );
311         table.m_glGetString = glGetString;
312         QGL_invalidateExtensionFunc( table.m_glGetTexEnvfv );
313         QGL_invalidateExtensionFunc( table.m_glGetTexEnviv );
314         QGL_invalidateExtensionFunc( table.m_glGetTexGendv );
315         QGL_invalidateExtensionFunc( table.m_glGetTexGenfv );
316         QGL_invalidateExtensionFunc( table.m_glGetTexGeniv );
317         QGL_invalidateExtensionFunc( table.m_glGetTexImage );
318         QGL_invalidateExtensionFunc( table.m_glGetTexLevelParameterfv );
319         QGL_invalidateExtensionFunc( table.m_glGetTexLevelParameteriv );
320         QGL_invalidateExtensionFunc( table.m_glGetTexParameterfv );
321         QGL_invalidateExtensionFunc( table.m_glGetTexParameteriv );
322         QGL_invalidateExtensionFunc( table.m_glHint );
323         QGL_invalidateExtensionFunc( table.m_glIndexMask );
324         QGL_invalidateExtensionFunc( table.m_glIndexPointer );
325         QGL_invalidateExtensionFunc( table.m_glIndexd );
326         QGL_invalidateExtensionFunc( table.m_glIndexdv );
327         QGL_invalidateExtensionFunc( table.m_glIndexf );
328         QGL_invalidateExtensionFunc( table.m_glIndexfv );
329         QGL_invalidateExtensionFunc( table.m_glIndexi );
330         QGL_invalidateExtensionFunc( table.m_glIndexiv );
331         QGL_invalidateExtensionFunc( table.m_glIndexs );
332         QGL_invalidateExtensionFunc( table.m_glIndexsv );
333         QGL_invalidateExtensionFunc( table.m_glIndexub );
334         QGL_invalidateExtensionFunc( table.m_glIndexubv );
335         QGL_invalidateExtensionFunc( table.m_glInitNames );
336         QGL_invalidateExtensionFunc( table.m_glInterleavedArrays );
337         QGL_invalidateExtensionFunc( table.m_glIsEnabled );
338         QGL_invalidateExtensionFunc( table.m_glIsList );
339         QGL_invalidateExtensionFunc( table.m_glIsTexture );
340         QGL_invalidateExtensionFunc( table.m_glLightModelf );
341         QGL_invalidateExtensionFunc( table.m_glLightModelfv );
342         QGL_invalidateExtensionFunc( table.m_glLightModeli );
343         QGL_invalidateExtensionFunc( table.m_glLightModeliv );
344         QGL_invalidateExtensionFunc( table.m_glLightf );
345         QGL_invalidateExtensionFunc( table.m_glLightfv );
346         QGL_invalidateExtensionFunc( table.m_glLighti );
347         QGL_invalidateExtensionFunc( table.m_glLightiv );
348         QGL_invalidateExtensionFunc( table.m_glLineStipple );
349         QGL_invalidateExtensionFunc( table.m_glLineWidth );
350         QGL_invalidateExtensionFunc( table.m_glListBase );
351         QGL_invalidateExtensionFunc( table.m_glLoadIdentity );
352         QGL_invalidateExtensionFunc( table.m_glLoadMatrixd );
353         QGL_invalidateExtensionFunc( table.m_glLoadMatrixf );
354         QGL_invalidateExtensionFunc( table.m_glLoadName );
355         QGL_invalidateExtensionFunc( table.m_glLogicOp );
356         QGL_invalidateExtensionFunc( table.m_glMap1d );
357         QGL_invalidateExtensionFunc( table.m_glMap1f );
358         QGL_invalidateExtensionFunc( table.m_glMap2d );
359         QGL_invalidateExtensionFunc( table.m_glMap2f );
360         QGL_invalidateExtensionFunc( table.m_glMapGrid1d );
361         QGL_invalidateExtensionFunc( table.m_glMapGrid1f );
362         QGL_invalidateExtensionFunc( table.m_glMapGrid2d );
363         QGL_invalidateExtensionFunc( table.m_glMapGrid2f );
364         QGL_invalidateExtensionFunc( table.m_glMaterialf );
365         QGL_invalidateExtensionFunc( table.m_glMaterialfv );
366         QGL_invalidateExtensionFunc( table.m_glMateriali );
367         QGL_invalidateExtensionFunc( table.m_glMaterialiv );
368         QGL_invalidateExtensionFunc( table.m_glMatrixMode );
369         QGL_invalidateExtensionFunc( table.m_glMultMatrixd );
370         QGL_invalidateExtensionFunc( table.m_glMultMatrixf );
371         QGL_invalidateExtensionFunc( table.m_glNewList );
372         QGL_invalidateExtensionFunc( table.m_glNormal3b );
373         QGL_invalidateExtensionFunc( table.m_glNormal3bv );
374         QGL_invalidateExtensionFunc( table.m_glNormal3d );
375         QGL_invalidateExtensionFunc( table.m_glNormal3dv );
376         QGL_invalidateExtensionFunc( table.m_glNormal3f );
377         QGL_invalidateExtensionFunc( table.m_glNormal3fv );
378         QGL_invalidateExtensionFunc( table.m_glNormal3i );
379         QGL_invalidateExtensionFunc( table.m_glNormal3iv );
380         QGL_invalidateExtensionFunc( table.m_glNormal3s );
381         QGL_invalidateExtensionFunc( table.m_glNormal3sv );
382         QGL_invalidateExtensionFunc( table.m_glNormalPointer );
383         QGL_invalidateExtensionFunc( table.m_glOrtho );
384         QGL_invalidateExtensionFunc( table.m_glPassThrough );
385         QGL_invalidateExtensionFunc( table.m_glPixelMapfv );
386         QGL_invalidateExtensionFunc( table.m_glPixelMapuiv );
387         QGL_invalidateExtensionFunc( table.m_glPixelMapusv );
388         QGL_invalidateExtensionFunc( table.m_glPixelStoref );
389         QGL_invalidateExtensionFunc( table.m_glPixelStorei );
390         QGL_invalidateExtensionFunc( table.m_glPixelTransferf );
391         QGL_invalidateExtensionFunc( table.m_glPixelTransferi );
392         QGL_invalidateExtensionFunc( table.m_glPixelZoom );
393         QGL_invalidateExtensionFunc( table.m_glPointSize );
394         QGL_invalidateExtensionFunc( table.m_glPolygonMode );
395         QGL_invalidateExtensionFunc( table.m_glPolygonOffset );
396         QGL_invalidateExtensionFunc( table.m_glPolygonStipple );
397         QGL_invalidateExtensionFunc( table.m_glPopAttrib );
398         QGL_invalidateExtensionFunc( table.m_glPopClientAttrib );
399         QGL_invalidateExtensionFunc( table.m_glPopMatrix );
400         QGL_invalidateExtensionFunc( table.m_glPopName );
401         QGL_invalidateExtensionFunc( table.m_glPrioritizeTextures );
402         QGL_invalidateExtensionFunc( table.m_glPushAttrib );
403         QGL_invalidateExtensionFunc( table.m_glPushClientAttrib );
404         QGL_invalidateExtensionFunc( table.m_glPushMatrix );
405         QGL_invalidateExtensionFunc( table.m_glPushName );
406         QGL_invalidateExtensionFunc( table.m_glRasterPos2d );
407         QGL_invalidateExtensionFunc( table.m_glRasterPos2dv );
408         QGL_invalidateExtensionFunc( table.m_glRasterPos2f );
409         QGL_invalidateExtensionFunc( table.m_glRasterPos2fv );
410         QGL_invalidateExtensionFunc( table.m_glRasterPos2i );
411         QGL_invalidateExtensionFunc( table.m_glRasterPos2iv );
412         QGL_invalidateExtensionFunc( table.m_glRasterPos2s );
413         QGL_invalidateExtensionFunc( table.m_glRasterPos2sv );
414         QGL_invalidateExtensionFunc( table.m_glRasterPos3d );
415         QGL_invalidateExtensionFunc( table.m_glRasterPos3dv );
416         QGL_invalidateExtensionFunc( table.m_glRasterPos3f );
417         QGL_invalidateExtensionFunc( table.m_glRasterPos3fv );
418         QGL_invalidateExtensionFunc( table.m_glRasterPos3i );
419         QGL_invalidateExtensionFunc( table.m_glRasterPos3iv );
420         QGL_invalidateExtensionFunc( table.m_glRasterPos3s );
421         QGL_invalidateExtensionFunc( table.m_glRasterPos3sv );
422         QGL_invalidateExtensionFunc( table.m_glRasterPos4d );
423         QGL_invalidateExtensionFunc( table.m_glRasterPos4dv );
424         QGL_invalidateExtensionFunc( table.m_glRasterPos4f );
425         QGL_invalidateExtensionFunc( table.m_glRasterPos4fv );
426         QGL_invalidateExtensionFunc( table.m_glRasterPos4i );
427         QGL_invalidateExtensionFunc( table.m_glRasterPos4iv );
428         QGL_invalidateExtensionFunc( table.m_glRasterPos4s );
429         QGL_invalidateExtensionFunc( table.m_glRasterPos4sv );
430         QGL_invalidateExtensionFunc( table.m_glReadBuffer );
431         QGL_invalidateExtensionFunc( table.m_glReadPixels );
432         QGL_invalidateExtensionFunc( table.m_glRectd );
433         QGL_invalidateExtensionFunc( table.m_glRectdv );
434         QGL_invalidateExtensionFunc( table.m_glRectf );
435         QGL_invalidateExtensionFunc( table.m_glRectfv );
436         QGL_invalidateExtensionFunc( table.m_glRecti );
437         QGL_invalidateExtensionFunc( table.m_glRectiv );
438         QGL_invalidateExtensionFunc( table.m_glRects );
439         QGL_invalidateExtensionFunc( table.m_glRectsv );
440         QGL_invalidateExtensionFunc( table.m_glRenderMode );
441         QGL_invalidateExtensionFunc( table.m_glRotated );
442         QGL_invalidateExtensionFunc( table.m_glRotatef );
443         QGL_invalidateExtensionFunc( table.m_glScaled );
444         QGL_invalidateExtensionFunc( table.m_glScalef );
445         QGL_invalidateExtensionFunc( table.m_glScissor );
446         QGL_invalidateExtensionFunc( table.m_glSelectBuffer );
447         QGL_invalidateExtensionFunc( table.m_glShadeModel );
448         QGL_invalidateExtensionFunc( table.m_glStencilFunc );
449         QGL_invalidateExtensionFunc( table.m_glStencilMask );
450         QGL_invalidateExtensionFunc( table.m_glStencilOp );
451         QGL_invalidateExtensionFunc( table.m_glTexCoord1d );
452         QGL_invalidateExtensionFunc( table.m_glTexCoord1dv );
453         QGL_invalidateExtensionFunc( table.m_glTexCoord1f );
454         QGL_invalidateExtensionFunc( table.m_glTexCoord1fv );
455         QGL_invalidateExtensionFunc( table.m_glTexCoord1i );
456         QGL_invalidateExtensionFunc( table.m_glTexCoord1iv );
457         QGL_invalidateExtensionFunc( table.m_glTexCoord1s );
458         QGL_invalidateExtensionFunc( table.m_glTexCoord1sv );
459         QGL_invalidateExtensionFunc( table.m_glTexCoord2d );
460         QGL_invalidateExtensionFunc( table.m_glTexCoord2dv );
461         QGL_invalidateExtensionFunc( table.m_glTexCoord2f );
462         QGL_invalidateExtensionFunc( table.m_glTexCoord2fv );
463         QGL_invalidateExtensionFunc( table.m_glTexCoord2i );
464         QGL_invalidateExtensionFunc( table.m_glTexCoord2iv );
465         QGL_invalidateExtensionFunc( table.m_glTexCoord2s );
466         QGL_invalidateExtensionFunc( table.m_glTexCoord2sv );
467         QGL_invalidateExtensionFunc( table.m_glTexCoord3d );
468         QGL_invalidateExtensionFunc( table.m_glTexCoord3dv );
469         QGL_invalidateExtensionFunc( table.m_glTexCoord3f );
470         QGL_invalidateExtensionFunc( table.m_glTexCoord3fv );
471         QGL_invalidateExtensionFunc( table.m_glTexCoord3i );
472         QGL_invalidateExtensionFunc( table.m_glTexCoord3iv );
473         QGL_invalidateExtensionFunc( table.m_glTexCoord3s );
474         QGL_invalidateExtensionFunc( table.m_glTexCoord3sv );
475         QGL_invalidateExtensionFunc( table.m_glTexCoord4d );
476         QGL_invalidateExtensionFunc( table.m_glTexCoord4dv );
477         QGL_invalidateExtensionFunc( table.m_glTexCoord4f );
478         QGL_invalidateExtensionFunc( table.m_glTexCoord4fv );
479         QGL_invalidateExtensionFunc( table.m_glTexCoord4i );
480         QGL_invalidateExtensionFunc( table.m_glTexCoord4iv );
481         QGL_invalidateExtensionFunc( table.m_glTexCoord4s );
482         QGL_invalidateExtensionFunc( table.m_glTexCoord4sv );
483         QGL_invalidateExtensionFunc( table.m_glTexCoordPointer );
484         QGL_invalidateExtensionFunc( table.m_glTexEnvf );
485         QGL_invalidateExtensionFunc( table.m_glTexEnvfv );
486         QGL_invalidateExtensionFunc( table.m_glTexEnvi );
487         QGL_invalidateExtensionFunc( table.m_glTexEnviv );
488         QGL_invalidateExtensionFunc( table.m_glTexGend );
489         QGL_invalidateExtensionFunc( table.m_glTexGendv );
490         QGL_invalidateExtensionFunc( table.m_glTexGenf );
491         QGL_invalidateExtensionFunc( table.m_glTexGenfv );
492         QGL_invalidateExtensionFunc( table.m_glTexGeni );
493         QGL_invalidateExtensionFunc( table.m_glTexGeniv );
494         QGL_invalidateExtensionFunc( table.m_glTexImage1D );
495         QGL_invalidateExtensionFunc( table.m_glTexImage2D );
496         QGL_invalidateExtensionFunc( table.m_glTexParameterf );
497         QGL_invalidateExtensionFunc( table.m_glTexParameterfv );
498         QGL_invalidateExtensionFunc( table.m_glTexParameteri );
499         QGL_invalidateExtensionFunc( table.m_glTexParameteriv );
500         QGL_invalidateExtensionFunc( table.m_glTexSubImage1D );
501         QGL_invalidateExtensionFunc( table.m_glTexSubImage2D );
502         QGL_invalidateExtensionFunc( table.m_glTranslated );
503         QGL_invalidateExtensionFunc( table.m_glTranslatef );
504         QGL_invalidateExtensionFunc( table.m_glVertex2d );
505         QGL_invalidateExtensionFunc( table.m_glVertex2dv );
506         QGL_invalidateExtensionFunc( table.m_glVertex2f );
507         QGL_invalidateExtensionFunc( table.m_glVertex2fv );
508         QGL_invalidateExtensionFunc( table.m_glVertex2i );
509         QGL_invalidateExtensionFunc( table.m_glVertex2iv );
510         QGL_invalidateExtensionFunc( table.m_glVertex2s );
511         QGL_invalidateExtensionFunc( table.m_glVertex2sv );
512         QGL_invalidateExtensionFunc( table.m_glVertex3d );
513         QGL_invalidateExtensionFunc( table.m_glVertex3dv );
514         QGL_invalidateExtensionFunc( table.m_glVertex3f );
515         QGL_invalidateExtensionFunc( table.m_glVertex3fv );
516         QGL_invalidateExtensionFunc( table.m_glVertex3i );
517         QGL_invalidateExtensionFunc( table.m_glVertex3iv );
518         QGL_invalidateExtensionFunc( table.m_glVertex3s );
519         QGL_invalidateExtensionFunc( table.m_glVertex3sv );
520         QGL_invalidateExtensionFunc( table.m_glVertex4d );
521         QGL_invalidateExtensionFunc( table.m_glVertex4dv );
522         QGL_invalidateExtensionFunc( table.m_glVertex4f );
523         QGL_invalidateExtensionFunc( table.m_glVertex4fv );
524         QGL_invalidateExtensionFunc( table.m_glVertex4i );
525         QGL_invalidateExtensionFunc( table.m_glVertex4iv );
526         QGL_invalidateExtensionFunc( table.m_glVertex4s );
527         QGL_invalidateExtensionFunc( table.m_glVertex4sv );
528         QGL_invalidateExtensionFunc( table.m_glVertexPointer );
529         QGL_invalidateExtensionFunc( table.m_glViewport );
530 }
531
532 int QGL_Init( OpenGLBinding& table ){
533         QGL_clear( table );
534
535 #if defined( WIN32 )
536         qwglGetProcAddress           = wglGetProcAddress;
537 #elif defined( XWINDOWS )
538         qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym( RTLD_DEFAULT, "glXGetProcAddressARB" );
539         if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension(XOpenDisplay(nullptr), 0, 0) != True ) ) {
540                 return 0;
541         }
542 #else
543 #error "unsupported platform"
544 #endif
545
546         return 1;
547 }
548
549 int g_qglMajorVersion = 0;
550 int g_qglMinorVersion = 0;
551
552 // requires a valid gl context
553 void QGL_InitVersion(){
554 #if EXTENSIONS_ENABLED
555         const std::size_t versionSize = 256;
556         char version[versionSize];
557         strncpy( version, reinterpret_cast<const char*>( GlobalOpenGL().m_glGetString( GL_VERSION ) ), versionSize - 1 );
558         version[versionSize - 1] = '\0';
559         char* firstDot = strchr( version, '.' );
560         ASSERT_NOTNULL( firstDot );
561         *firstDot = '\0';
562         g_qglMajorVersion = atoi( version );
563         char* secondDot = strchr( firstDot + 1, '.' );
564         if ( secondDot != 0 ) {
565                 *secondDot = '\0';
566         }
567         g_qglMinorVersion = atoi( firstDot + 1 );
568 #else
569         g_qglMajorVersion = 1;
570         g_qglMinorVersion = 1;
571 #endif
572 }
573
574
575 inline void extension_not_implemented( const char* extension ){
576         globalErrorStream() << "WARNING: OpenGL driver reports support for " << extension << " but does not implement it\n";
577 }
578
579 float g_maxTextureAnisotropy;
580
581 float QGL_maxTextureAnisotropy(){
582         return g_maxTextureAnisotropy;
583 }
584
585 void QGL_sharedContextCreated( OpenGLBinding& table ){
586         QGL_InitVersion();
587
588         table.major_version = g_qglMajorVersion;
589         table.minor_version = g_qglMinorVersion;
590
591         table.m_glAccum                     = glAccum;
592         table.m_glAlphaFunc                 = glAlphaFunc;
593         table.m_glAreTexturesResident       = glAreTexturesResident;
594         table.m_glArrayElement              = glArrayElement;
595         table.m_glBegin                     = glBegin;
596         table.m_glBindTexture               = glBindTexture;
597         table.m_glBitmap                    = glBitmap;
598         table.m_glBlendFunc                 = glBlendFunc;
599         table.m_glCallList                  = glCallList;
600         table.m_glCallLists                 = glCallLists;
601         table.m_glClear                     = glClear;
602         table.m_glClearAccum                = glClearAccum;
603         table.m_glClearColor                = glClearColor;
604         table.m_glClearDepth                = glClearDepth;
605         table.m_glClearIndex                = glClearIndex;
606         table.m_glClearStencil              = glClearStencil;
607         table.m_glClipPlane                 = glClipPlane;
608         table.m_glColor3b                   = glColor3b;
609         table.m_glColor3bv                  = glColor3bv;
610         table.m_glColor3d                   = glColor3d;
611         table.m_glColor3dv                  = glColor3dv;
612         table.m_glColor3f                   = glColor3f;
613         table.m_glColor3fv                  = glColor3fv;
614         table.m_glColor3i                   = glColor3i;
615         table.m_glColor3iv                  = glColor3iv;
616         table.m_glColor3s                   = glColor3s;
617         table.m_glColor3sv                  = glColor3sv;
618         table.m_glColor3ub                  = glColor3ub;
619         table.m_glColor3ubv                 = glColor3ubv;
620         table.m_glColor3ui                  = glColor3ui;
621         table.m_glColor3uiv                 = glColor3uiv;
622         table.m_glColor3us                  = glColor3us;
623         table.m_glColor3usv                 = glColor3usv;
624         table.m_glColor4b                   = glColor4b;
625         table.m_glColor4bv                  = glColor4bv;
626         table.m_glColor4d                   = glColor4d;
627         table.m_glColor4dv                  = glColor4dv;
628         table.m_glColor4f                   = glColor4f;
629         table.m_glColor4fv                  = glColor4fv;
630         table.m_glColor4i                   = glColor4i;
631         table.m_glColor4iv                  = glColor4iv;
632         table.m_glColor4s                   = glColor4s;
633         table.m_glColor4sv                  = glColor4sv;
634         table.m_glColor4ub                  = glColor4ub;
635         table.m_glColor4ubv                 = glColor4ubv;
636         table.m_glColor4ui                  = glColor4ui;
637         table.m_glColor4uiv                 = glColor4uiv;
638         table.m_glColor4us                  = glColor4us;
639         table.m_glColor4usv                 = glColor4usv;
640         table.m_glColorMask                 = glColorMask;
641         table.m_glColorMaterial             = glColorMaterial;
642         table.m_glColorPointer              = glColorPointer;
643         table.m_glCopyPixels                = glCopyPixels;
644         table.m_glCopyTexImage1D            = glCopyTexImage1D;
645         table.m_glCopyTexImage2D            = glCopyTexImage2D;
646         table.m_glCopyTexSubImage1D         = glCopyTexSubImage1D;
647         table.m_glCopyTexSubImage2D         = glCopyTexSubImage2D;
648         table.m_glCullFace                  = glCullFace;
649         table.m_glDeleteLists               = glDeleteLists;
650         table.m_glDeleteTextures            = glDeleteTextures;
651         table.m_glDepthFunc                 = glDepthFunc;
652         table.m_glDepthMask                 = glDepthMask;
653         table.m_glDepthRange                = glDepthRange;
654         table.m_glDisable                   = glDisable;
655         table.m_glDisableClientState        = glDisableClientState;
656         table.m_glDrawArrays                = glDrawArrays;
657         table.m_glDrawBuffer                = glDrawBuffer;
658         table.m_glDrawElements              = glDrawElements;
659         table.m_glDrawPixels                = glDrawPixels;
660         table.m_glEdgeFlag                  = glEdgeFlag;
661         table.m_glEdgeFlagPointer           = glEdgeFlagPointer;
662         table.m_glEdgeFlagv                 = glEdgeFlagv;
663         table.m_glEnable                    = glEnable;
664         table.m_glEnableClientState         = glEnableClientState;
665         table.m_glEnd                       = glEnd;
666         table.m_glEndList                   = glEndList;
667         table.m_glEvalCoord1d               = glEvalCoord1d;
668         table.m_glEvalCoord1dv              = glEvalCoord1dv;
669         table.m_glEvalCoord1f               = glEvalCoord1f;
670         table.m_glEvalCoord1fv              = glEvalCoord1fv;
671         table.m_glEvalCoord2d               = glEvalCoord2d;
672         table.m_glEvalCoord2dv              = glEvalCoord2dv;
673         table.m_glEvalCoord2f               = glEvalCoord2f;
674         table.m_glEvalCoord2fv              = glEvalCoord2fv;
675         table.m_glEvalMesh1                 = glEvalMesh1;
676         table.m_glEvalMesh2                 = glEvalMesh2;
677         table.m_glEvalPoint1                = glEvalPoint1;
678         table.m_glEvalPoint2                = glEvalPoint2;
679         table.m_glFeedbackBuffer            = glFeedbackBuffer;
680         table.m_glFinish                    = glFinish;
681         table.m_glFlush                     = glFlush;
682         table.m_glFogf                      = glFogf;
683         table.m_glFogfv                     = glFogfv;
684         table.m_glFogi                      = glFogi;
685         table.m_glFogiv                     = glFogiv;
686         table.m_glFrontFace                 = glFrontFace;
687         table.m_glFrustum                   = glFrustum;
688         table.m_glGenLists                  = glGenLists;
689         table.m_glGenTextures               = glGenTextures;
690         table.m_glGetBooleanv               = glGetBooleanv;
691         table.m_glGetClipPlane              = glGetClipPlane;
692         table.m_glGetDoublev                = glGetDoublev;
693         table.m_glGetError                  = glGetError;
694         table.m_glGetFloatv                 = glGetFloatv;
695         table.m_glGetIntegerv               = glGetIntegerv;
696         table.m_glGetLightfv                = glGetLightfv;
697         table.m_glGetLightiv                = glGetLightiv;
698         table.m_glGetMapdv                  = glGetMapdv;
699         table.m_glGetMapfv                  = glGetMapfv;
700         table.m_glGetMapiv                  = glGetMapiv;
701         table.m_glGetMaterialfv             = glGetMaterialfv;
702         table.m_glGetMaterialiv             = glGetMaterialiv;
703         table.m_glGetPixelMapfv             = glGetPixelMapfv;
704         table.m_glGetPixelMapuiv            = glGetPixelMapuiv;
705         table.m_glGetPixelMapusv            = glGetPixelMapusv;
706         table.m_glGetPointerv               = glGetPointerv;
707         table.m_glGetPolygonStipple         = glGetPolygonStipple;
708         table.m_glGetString                 = glGetString;
709         table.m_glGetTexEnvfv               = glGetTexEnvfv;
710         table.m_glGetTexEnviv               = glGetTexEnviv;
711         table.m_glGetTexGendv               = glGetTexGendv;
712         table.m_glGetTexGenfv               = glGetTexGenfv;
713         table.m_glGetTexGeniv               = glGetTexGeniv;
714         table.m_glGetTexImage               = glGetTexImage;
715         table.m_glGetTexLevelParameterfv    = glGetTexLevelParameterfv;
716         table.m_glGetTexLevelParameteriv    = glGetTexLevelParameteriv;
717         table.m_glGetTexParameterfv         = glGetTexParameterfv;
718         table.m_glGetTexParameteriv         = glGetTexParameteriv;
719         table.m_glHint                      = glHint;
720         table.m_glIndexMask                 = glIndexMask;
721         table.m_glIndexPointer              = glIndexPointer;
722         table.m_glIndexd                    = glIndexd;
723         table.m_glIndexdv                   = glIndexdv;
724         table.m_glIndexf                    = glIndexf;
725         table.m_glIndexfv                   = glIndexfv;
726         table.m_glIndexi                    = glIndexi;
727         table.m_glIndexiv                   = glIndexiv;
728         table.m_glIndexs                    = glIndexs;
729         table.m_glIndexsv                   = glIndexsv;
730         table.m_glIndexub                   = glIndexub;
731         table.m_glIndexubv                  = glIndexubv;
732         table.m_glInitNames                 = glInitNames;
733         table.m_glInterleavedArrays         = glInterleavedArrays;
734         table.m_glIsEnabled                 = glIsEnabled;
735         table.m_glIsList                    = glIsList;
736         table.m_glIsTexture                 = glIsTexture;
737         table.m_glLightModelf               = glLightModelf;
738         table.m_glLightModelfv              = glLightModelfv;
739         table.m_glLightModeli               = glLightModeli;
740         table.m_glLightModeliv              = glLightModeliv;
741         table.m_glLightf                    = glLightf;
742         table.m_glLightfv                   = glLightfv;
743         table.m_glLighti                    = glLighti;
744         table.m_glLightiv                   = glLightiv;
745         table.m_glLineStipple               = glLineStipple;
746         table.m_glLineWidth                 = glLineWidth;
747         table.m_glListBase                  = glListBase;
748         table.m_glLoadIdentity              = glLoadIdentity;
749         table.m_glLoadMatrixd               = glLoadMatrixd;
750         table.m_glLoadMatrixf               = glLoadMatrixf;
751         table.m_glLoadName                  = glLoadName;
752         table.m_glLogicOp                   = glLogicOp;
753         table.m_glMap1d                     = glMap1d;
754         table.m_glMap1f                     = glMap1f;
755         table.m_glMap2d                     = glMap2d;
756         table.m_glMap2f                     = glMap2f;
757         table.m_glMapGrid1d                 = glMapGrid1d;
758         table.m_glMapGrid1f                 = glMapGrid1f;
759         table.m_glMapGrid2d                 = glMapGrid2d;
760         table.m_glMapGrid2f                 = glMapGrid2f;
761         table.m_glMaterialf                 = glMaterialf;
762         table.m_glMaterialfv                = glMaterialfv;
763         table.m_glMateriali                 = glMateriali;
764         table.m_glMaterialiv                = glMaterialiv;
765         table.m_glMatrixMode                = glMatrixMode;
766         table.m_glMultMatrixd               = glMultMatrixd;
767         table.m_glMultMatrixf               = glMultMatrixf;
768         table.m_glNewList                   = glNewList;
769         table.m_glNormal3b                  = glNormal3b;
770         table.m_glNormal3bv                 = glNormal3bv;
771         table.m_glNormal3d                  = glNormal3d;
772         table.m_glNormal3dv                 = glNormal3dv;
773         table.m_glNormal3f                  = glNormal3f;
774         table.m_glNormal3fv                 = glNormal3fv;
775         table.m_glNormal3i                  = glNormal3i;
776         table.m_glNormal3iv                 = glNormal3iv;
777         table.m_glNormal3s                  = glNormal3s;
778         table.m_glNormal3sv                 = glNormal3sv;
779         table.m_glNormalPointer             = glNormalPointer;
780         table.m_glOrtho                     = glOrtho;
781         table.m_glPassThrough               = glPassThrough;
782         table.m_glPixelMapfv                = glPixelMapfv;
783         table.m_glPixelMapuiv               = glPixelMapuiv;
784         table.m_glPixelMapusv               = glPixelMapusv;
785         table.m_glPixelStoref               = glPixelStoref;
786         table.m_glPixelStorei               = glPixelStorei;
787         table.m_glPixelTransferf            = glPixelTransferf;
788         table.m_glPixelTransferi            = glPixelTransferi;
789         table.m_glPixelZoom                 = glPixelZoom;
790         table.m_glPointSize                 = glPointSize;
791         table.m_glPolygonMode               = glPolygonMode;
792         table.m_glPolygonOffset             = glPolygonOffset;
793         table.m_glPolygonStipple            = glPolygonStipple;
794         table.m_glPopAttrib                 = glPopAttrib;
795         table.m_glPopClientAttrib           = glPopClientAttrib;
796         table.m_glPopMatrix                 = glPopMatrix;
797         table.m_glPopName                   = glPopName;
798         table.m_glPrioritizeTextures        = glPrioritizeTextures;
799         table.m_glPushAttrib                = glPushAttrib;
800         table.m_glPushClientAttrib          = glPushClientAttrib;
801         table.m_glPushMatrix                = glPushMatrix;
802         table.m_glPushName                  = glPushName;
803         table.m_glRasterPos2d               = glRasterPos2d;
804         table.m_glRasterPos2dv              = glRasterPos2dv;
805         table.m_glRasterPos2f               = glRasterPos2f;
806         table.m_glRasterPos2fv              = glRasterPos2fv;
807         table.m_glRasterPos2i               = glRasterPos2i;
808         table.m_glRasterPos2iv              = glRasterPos2iv;
809         table.m_glRasterPos2s               = glRasterPos2s;
810         table.m_glRasterPos2sv              = glRasterPos2sv;
811         table.m_glRasterPos3d               = glRasterPos3d;
812         table.m_glRasterPos3dv              = glRasterPos3dv;
813         table.m_glRasterPos3f               = glRasterPos3f;
814         table.m_glRasterPos3fv              = glRasterPos3fv;
815         table.m_glRasterPos3i               = glRasterPos3i;
816         table.m_glRasterPos3iv              = glRasterPos3iv;
817         table.m_glRasterPos3s               = glRasterPos3s;
818         table.m_glRasterPos3sv              = glRasterPos3sv;
819         table.m_glRasterPos4d               = glRasterPos4d;
820         table.m_glRasterPos4dv              = glRasterPos4dv;
821         table.m_glRasterPos4f               = glRasterPos4f;
822         table.m_glRasterPos4fv              = glRasterPos4fv;
823         table.m_glRasterPos4i               = glRasterPos4i;
824         table.m_glRasterPos4iv              = glRasterPos4iv;
825         table.m_glRasterPos4s               = glRasterPos4s;
826         table.m_glRasterPos4sv              = glRasterPos4sv;
827         table.m_glReadBuffer                = glReadBuffer;
828         table.m_glReadPixels                = glReadPixels;
829         table.m_glRectd                     = glRectd;
830         table.m_glRectdv                    = glRectdv;
831         table.m_glRectf                     = glRectf;
832         table.m_glRectfv                    = glRectfv;
833         table.m_glRecti                     = glRecti;
834         table.m_glRectiv                    = glRectiv;
835         table.m_glRects                     = glRects;
836         table.m_glRectsv                    = glRectsv;
837         table.m_glRenderMode                = glRenderMode;
838         table.m_glRotated                   = glRotated;
839         table.m_glRotatef                   = glRotatef;
840         table.m_glScaled                    = glScaled;
841         table.m_glScalef                    = glScalef;
842         table.m_glScissor                   = glScissor;
843         table.m_glSelectBuffer              = glSelectBuffer;
844         table.m_glShadeModel                = glShadeModel;
845         table.m_glStencilFunc               = glStencilFunc;
846         table.m_glStencilMask               = glStencilMask;
847         table.m_glStencilOp                 = glStencilOp;
848         table.m_glTexCoord1d                = glTexCoord1d;
849         table.m_glTexCoord1dv               = glTexCoord1dv;
850         table.m_glTexCoord1f                = glTexCoord1f;
851         table.m_glTexCoord1fv               = glTexCoord1fv;
852         table.m_glTexCoord1i                = glTexCoord1i;
853         table.m_glTexCoord1iv               = glTexCoord1iv;
854         table.m_glTexCoord1s                = glTexCoord1s;
855         table.m_glTexCoord1sv               = glTexCoord1sv;
856         table.m_glTexCoord2d                = glTexCoord2d;
857         table.m_glTexCoord2dv               = glTexCoord2dv;
858         table.m_glTexCoord2f                = glTexCoord2f;
859         table.m_glTexCoord2fv               = glTexCoord2fv;
860         table.m_glTexCoord2i                = glTexCoord2i;
861         table.m_glTexCoord2iv               = glTexCoord2iv;
862         table.m_glTexCoord2s                = glTexCoord2s;
863         table.m_glTexCoord2sv               = glTexCoord2sv;
864         table.m_glTexCoord3d                = glTexCoord3d;
865         table.m_glTexCoord3dv               = glTexCoord3dv;
866         table.m_glTexCoord3f                = glTexCoord3f;
867         table.m_glTexCoord3fv               = glTexCoord3fv;
868         table.m_glTexCoord3i                = glTexCoord3i;
869         table.m_glTexCoord3iv               = glTexCoord3iv;
870         table.m_glTexCoord3s                = glTexCoord3s;
871         table.m_glTexCoord3sv               = glTexCoord3sv;
872         table.m_glTexCoord4d                = glTexCoord4d;
873         table.m_glTexCoord4dv               = glTexCoord4dv;
874         table.m_glTexCoord4f                = glTexCoord4f;
875         table.m_glTexCoord4fv               = glTexCoord4fv;
876         table.m_glTexCoord4i                = glTexCoord4i;
877         table.m_glTexCoord4iv               = glTexCoord4iv;
878         table.m_glTexCoord4s                = glTexCoord4s;
879         table.m_glTexCoord4sv               = glTexCoord4sv;
880         table.m_glTexCoordPointer           = glTexCoordPointer;
881         table.m_glTexEnvf                   = glTexEnvf;
882         table.m_glTexEnvfv                  = glTexEnvfv;
883         table.m_glTexEnvi                   = glTexEnvi;
884         table.m_glTexEnviv                  = glTexEnviv;
885         table.m_glTexGend                   = glTexGend;
886         table.m_glTexGendv                  = glTexGendv;
887         table.m_glTexGenf                   = glTexGenf;
888         table.m_glTexGenfv                  = glTexGenfv;
889         table.m_glTexGeni                   = glTexGeni;
890         table.m_glTexGeniv                  = glTexGeniv;
891         table.m_glTexImage1D                = glTexImage1D;
892         table.m_glTexImage2D                = glTexImage2D;
893         table.m_glTexParameterf             = glTexParameterf;
894         table.m_glTexParameterfv            = glTexParameterfv;
895         table.m_glTexParameteri             = glTexParameteri;
896         table.m_glTexParameteriv            = glTexParameteriv;
897         table.m_glTexSubImage1D             = glTexSubImage1D;
898         table.m_glTexSubImage2D             = glTexSubImage2D;
899         table.m_glTranslated                = glTranslated;
900         table.m_glTranslatef                = glTranslatef;
901         table.m_glVertex2d                  = glVertex2d;
902         table.m_glVertex2dv                 = glVertex2dv;
903         table.m_glVertex2f                  = glVertex2f;
904         table.m_glVertex2fv                 = glVertex2fv;
905         table.m_glVertex2i                  = glVertex2i;
906         table.m_glVertex2iv                 = glVertex2iv;
907         table.m_glVertex2s                  = glVertex2s;
908         table.m_glVertex2sv                 = glVertex2sv;
909         table.m_glVertex3d                  = glVertex3d;
910         table.m_glVertex3dv                 = glVertex3dv;
911         table.m_glVertex3f                  = glVertex3f;
912         table.m_glVertex3fv                 = glVertex3fv;
913         table.m_glVertex3i                  = glVertex3i;
914         table.m_glVertex3iv                 = glVertex3iv;
915         table.m_glVertex3s                  = glVertex3s;
916         table.m_glVertex3sv                 = glVertex3sv;
917         table.m_glVertex4d                  = glVertex4d;
918         table.m_glVertex4dv                 = glVertex4dv;
919         table.m_glVertex4f                  = glVertex4f;
920         table.m_glVertex4fv                 = glVertex4fv;
921         table.m_glVertex4i                  = glVertex4i;
922         table.m_glVertex4iv                 = glVertex4iv;
923         table.m_glVertex4s                  = glVertex4s;
924         table.m_glVertex4sv                 = glVertex4sv;
925         table.m_glVertexPointer             = glVertexPointer;
926         table.m_glViewport                  = glViewport;
927
928         if ( QGL_ExtensionSupported( "GL_ARB_multitexture" ) ) {
929                 table.support_ARB_multitexture =
930                         QGL_constructExtensionFunc( table.m_glActiveTextureARB, "glActiveTextureARB" )
931                         && QGL_constructExtensionFunc( table.m_glClientActiveTextureARB, "glClientActiveTextureARB" )
932                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1dARB, "glMultiTexCoord1dARB" )
933                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1dvARB, "glMultiTexCoord1dvARB" )
934                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1fARB, "glMultiTexCoord1fARB" )
935                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1fvARB, "glMultiTexCoord1fvARB" )
936                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1iARB, "glMultiTexCoord1iARB" )
937                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1ivARB, "glMultiTexCoord1ivARB" )
938                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1sARB, "glMultiTexCoord1sARB" )
939                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1svARB, "glMultiTexCoord1svARB" )
940                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2dARB, "glMultiTexCoord2dARB" )
941                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2dvARB, "glMultiTexCoord2dvARB" )
942                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2fARB, "glMultiTexCoord2fARB" )
943                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2fvARB, "glMultiTexCoord2fvARB" )
944                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2iARB, "glMultiTexCoord2iARB" )
945                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2ivARB, "glMultiTexCoord2ivARB" )
946                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2sARB, "glMultiTexCoord2sARB" )
947                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2svARB, "glMultiTexCoord2svARB" )
948                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3dARB, "glMultiTexCoord3dARB" )
949                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3dvARB, "glMultiTexCoord3dvARB" )
950                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3fARB, "glMultiTexCoord3fARB" )
951                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3fvARB, "glMultiTexCoord3fvARB" )
952                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3iARB, "glMultiTexCoord3iARB" )
953                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3ivARB, "glMultiTexCoord3ivARB" )
954                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3sARB, "glMultiTexCoord3sARB" )
955                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3svARB, "glMultiTexCoord3svARB" )
956                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4dARB, "glMultiTexCoord4dARB" )
957                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4dvARB, "glMultiTexCoord4dvARB" )
958                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4fARB, "glMultiTexCoord4fARB" )
959                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4fvARB, "glMultiTexCoord4fvARB" )
960                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4iARB, "glMultiTexCoord4iARB" )
961                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4ivARB, "glMultiTexCoord4ivARB" )
962                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4sARB, "glMultiTexCoord4sARB" )
963                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4svARB, "glMultiTexCoord4svARB" );
964
965                 if ( !table.support_ARB_multitexture ) {
966                         extension_not_implemented( "GL_ARB_multitexture" );
967                 }
968         }
969         else
970         {
971                 table.support_ARB_multitexture = false;
972         }
973
974         if ( QGL_ExtensionSupported( "GL_ARB_texture_compression" ) ) {
975                 table.support_ARB_texture_compression =
976                         QGL_constructExtensionFunc( table.m_glCompressedTexImage3DARB, "glCompressedTexImage3DARB" )
977                         && QGL_constructExtensionFunc( table.m_glCompressedTexImage2DARB, "glCompressedTexImage2DARB" )
978                         && QGL_constructExtensionFunc( table.m_glCompressedTexImage1DARB, "glCompressedTexImage1DARB" )
979                         && QGL_constructExtensionFunc( table.m_glCompressedTexSubImage3DARB, "glCompressedTexSubImage3DARB" )
980                         && QGL_constructExtensionFunc( table.m_glCompressedTexSubImage2DARB, "glCompressedTexSubImage2DARB" )
981                         && QGL_constructExtensionFunc( table.m_glCompressedTexSubImage1DARB, "glCompressedTexSubImage1DARB" )
982                         && QGL_constructExtensionFunc( table.m_glGetCompressedTexImageARB, "glGetCompressedTexImageARB" );
983
984                 if ( !table.support_ARB_texture_compression ) {
985                         extension_not_implemented( "GL_ARB_texture_compression" );
986                 }
987         }
988         else
989         {
990                 table.support_ARB_texture_compression = false;
991         }
992
993         table.support_EXT_texture_compression_s3tc = QGL_ExtensionSupported( "GL_EXT_texture_compression_s3tc" );
994
995         // GL 1.2
996         if ( table.major_version > 1 || table.minor_version >= 2 ) {
997                 table.support_GL_1_2 =
998                         QGL_constructExtensionFunc( table.m_glCopyTexSubImage3D, "glCopyTexSubImage3D" )
999                         && QGL_constructExtensionFunc( table.m_glDrawRangeElements, "glDrawRangeElements" )
1000                         && QGL_constructExtensionFunc( table.m_glTexImage3D, "glTexImage3D" )
1001                         && QGL_constructExtensionFunc( table.m_glTexSubImage3D, "glTexSubImage3D" );
1002
1003                 if ( !table.support_GL_1_2 ) {
1004                         extension_not_implemented( "GL_VERSION_1_2" );
1005                 }
1006         }
1007         else
1008         {
1009                 table.support_GL_1_2 = false;
1010         }
1011
1012         // GL 1.3
1013         if ( table.major_version > 1 || table.minor_version >= 3 ) {
1014                 table.support_GL_1_3 =
1015                         QGL_constructExtensionFunc( table.m_glActiveTexture, "glActiveTexture" )
1016                         && QGL_constructExtensionFunc( table.m_glClientActiveTexture, "glClientActiveTexture" )
1017                         && QGL_constructExtensionFunc( table.m_glCompressedTexImage1D, "glCompressedTexImage1D" )
1018                         && QGL_constructExtensionFunc( table.m_glCompressedTexImage2D, "glCompressedTexImage2D" )
1019                         && QGL_constructExtensionFunc( table.m_glCompressedTexImage3D, "glCompressedTexImage3D" )
1020                         && QGL_constructExtensionFunc( table.m_glCompressedTexSubImage1D, "glCompressedTexSubImage1D" )
1021                         && QGL_constructExtensionFunc( table.m_glCompressedTexSubImage2D, "glCompressedTexSubImage2D" )
1022                         && QGL_constructExtensionFunc( table.m_glCompressedTexSubImage3D, "glCompressedTexSubImage3D" )
1023                         && QGL_constructExtensionFunc( table.m_glGetCompressedTexImage, "glGetCompressedTexImage" )
1024                         && QGL_constructExtensionFunc( table.m_glLoadTransposeMatrixd, "glLoadTransposeMatrixd" )
1025                         && QGL_constructExtensionFunc( table.m_glLoadTransposeMatrixf, "glLoadTransposeMatrixf" )
1026                         && QGL_constructExtensionFunc( table.m_glMultTransposeMatrixd, "glMultTransposeMatrixd" )
1027                         && QGL_constructExtensionFunc( table.m_glMultTransposeMatrixf, "glMultTransposeMatrixf" )
1028                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1d, "glMultiTexCoord1d" )
1029                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1dv, "glMultiTexCoord1dv" )
1030                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1f, "glMultiTexCoord1f" )
1031                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1fv, "glMultiTexCoord1fv" )
1032                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1i, "glMultiTexCoord1i" )
1033                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1iv, "glMultiTexCoord1iv" )
1034                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1s, "glMultiTexCoord1s" )
1035                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord1sv, "glMultiTexCoord1sv" )
1036                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2d, "glMultiTexCoord2d" )
1037                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2dv, "glMultiTexCoord2dv" )
1038                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2f, "glMultiTexCoord2f" )
1039                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2fv, "glMultiTexCoord2fv" )
1040                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2i, "glMultiTexCoord2i" )
1041                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2iv, "glMultiTexCoord2iv" )
1042                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2s, "glMultiTexCoord2s" )
1043                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord2sv, "glMultiTexCoord2sv" )
1044                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3d, "glMultiTexCoord3d" )
1045                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3dv, "glMultiTexCoord3dv" )
1046                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3f, "glMultiTexCoord3f" )
1047                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3fv, "glMultiTexCoord3fv" )
1048                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3i, "glMultiTexCoord3i" )
1049                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3iv, "glMultiTexCoord3iv" )
1050                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3s, "glMultiTexCoord3s" )
1051                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord3sv, "glMultiTexCoord3sv" )
1052                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4d, "glMultiTexCoord4d" )
1053                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4dv, "glMultiTexCoord4dv" )
1054                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4f, "glMultiTexCoord4f" )
1055                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4fv, "glMultiTexCoord4fv" )
1056                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4i, "glMultiTexCoord4i" )
1057                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4iv, "glMultiTexCoord4iv" )
1058                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4s, "glMultiTexCoord4s" )
1059                         && QGL_constructExtensionFunc( table.m_glMultiTexCoord4sv, "glMultiTexCoord4sv" )
1060                         && QGL_constructExtensionFunc( table.m_glSampleCoverage, "glSampleCoverage" );
1061
1062                 if ( !table.support_GL_1_3 ) {
1063                         extension_not_implemented( "GL_VERSION_1_3" );
1064                 }
1065         }
1066         else
1067         {
1068                 table.support_GL_1_3 = false;
1069         }
1070
1071         // GL 1.4
1072         if ( table.major_version > 1 || table.minor_version >= 4 ) {
1073                 table.support_GL_1_4 =
1074                         QGL_constructExtensionFunc( table.m_glBlendColor, "glBlendColor" )
1075                         && QGL_constructExtensionFunc( table.m_glBlendEquation, "glBlendEquation" )
1076                         && QGL_constructExtensionFunc( table.m_glBlendFuncSeparate, "glBlendFuncSeparate" )
1077                         && QGL_constructExtensionFunc( table.m_glFogCoordPointer, "glFogCoordPointer" )
1078                         && QGL_constructExtensionFunc( table.m_glFogCoordd, "glFogCoordd" )
1079                         && QGL_constructExtensionFunc( table.m_glFogCoorddv, "glFogCoorddv" )
1080                         && QGL_constructExtensionFunc( table.m_glFogCoordf, "glFogCoordf" )
1081                         && QGL_constructExtensionFunc( table.m_glFogCoordfv, "glFogCoordfv" )
1082                         && QGL_constructExtensionFunc( table.m_glMultiDrawArrays, "glMultiDrawArrays" )
1083                         && QGL_constructExtensionFunc( table.m_glMultiDrawElements, "glMultiDrawElements" )
1084                         && QGL_constructExtensionFunc( table.m_glPointParameterf, "glPointParameterf" )
1085                         && QGL_constructExtensionFunc( table.m_glPointParameterfv, "glPointParameterfv" )
1086                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3b, "glSecondaryColor3b" )
1087                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3bv, "glSecondaryColor3bv" )
1088                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3d, "glSecondaryColor3d" )
1089                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3dv, "glSecondaryColor3dv" )
1090                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3f, "glSecondaryColor3f" )
1091                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3fv, "glSecondaryColor3fv" )
1092                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3i, "glSecondaryColor3i" )
1093                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3iv, "glSecondaryColor3iv" )
1094                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3s, "glSecondaryColor3s" )
1095                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3sv, "glSecondaryColor3sv" )
1096                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3ub, "glSecondaryColor3ub" )
1097                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3ubv, "glSecondaryColor3ubv" )
1098                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3ui, "glSecondaryColor3ui" )
1099                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3uiv, "glSecondaryColor3uiv" )
1100                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3us, "glSecondaryColor3us" )
1101                         && QGL_constructExtensionFunc( table.m_glSecondaryColor3usv, "glSecondaryColor3usv" )
1102                         && QGL_constructExtensionFunc( table.m_glSecondaryColorPointer, "glSecondaryColorPointer" )
1103                         && QGL_constructExtensionFunc( table.m_glWindowPos2d, "glWindowPos2d" )
1104                         && QGL_constructExtensionFunc( table.m_glWindowPos2dv, "glWindowPos2dv" )
1105                         && QGL_constructExtensionFunc( table.m_glWindowPos2f, "glWindowPos2f" )
1106                         && QGL_constructExtensionFunc( table.m_glWindowPos2fv, "glWindowPos2fv" )
1107                         && QGL_constructExtensionFunc( table.m_glWindowPos2i, "glWindowPos2i" )
1108                         && QGL_constructExtensionFunc( table.m_glWindowPos2iv, "glWindowPos2iv" )
1109                         && QGL_constructExtensionFunc( table.m_glWindowPos2s, "glWindowPos2s" )
1110                         && QGL_constructExtensionFunc( table.m_glWindowPos2sv, "glWindowPos2sv" )
1111                         && QGL_constructExtensionFunc( table.m_glWindowPos3d, "glWindowPos3d" )
1112                         && QGL_constructExtensionFunc( table.m_glWindowPos3dv, "glWindowPos3dv" )
1113                         && QGL_constructExtensionFunc( table.m_glWindowPos3f, "glWindowPos3f" )
1114                         && QGL_constructExtensionFunc( table.m_glWindowPos3fv, "glWindowPos3fv" )
1115                         && QGL_constructExtensionFunc( table.m_glWindowPos3i, "glWindowPos3i" )
1116                         && QGL_constructExtensionFunc( table.m_glWindowPos3iv, "glWindowPos3iv" )
1117                         && QGL_constructExtensionFunc( table.m_glWindowPos3s, "glWindowPos3s" )
1118                         && QGL_constructExtensionFunc( table.m_glWindowPos3sv, "glWindowPos3sv" );
1119
1120                 if ( !table.support_GL_1_4 ) {
1121                         extension_not_implemented( "GL_VERSION_1_4" );
1122                 }
1123         }
1124         else
1125         {
1126                 table.support_GL_1_4 = false;
1127         }
1128
1129         // GL 1.5
1130         if ( table.major_version > 1 || table.minor_version >= 5 ) {
1131                 table.support_GL_1_5 =
1132                         QGL_constructExtensionFunc( table.m_glBeginQuery, "glBeginQuery" )
1133                         && QGL_constructExtensionFunc( table.m_glBindBuffer, "glBindBuffer" )
1134                         && QGL_constructExtensionFunc( table.m_glBufferData, "glBufferData" )
1135                         && QGL_constructExtensionFunc( table.m_glBufferSubData, "glBufferSubData" )
1136                         && QGL_constructExtensionFunc( table.m_glDeleteBuffers, "glDeleteBuffers" )
1137                         && QGL_constructExtensionFunc( table.m_glDeleteQueries, "glDeleteQueries" )
1138                         && QGL_constructExtensionFunc( table.m_glEndQuery, "glEndQuery" )
1139                         && QGL_constructExtensionFunc( table.m_glGenBuffers, "glGenBuffers" )
1140                         && QGL_constructExtensionFunc( table.m_glGenQueries, "glGenQueries" )
1141                         && QGL_constructExtensionFunc( table.m_glGetBufferParameteriv, "glGetBufferParameteriv" )
1142                         && QGL_constructExtensionFunc( table.m_glGetBufferPointerv, "glGetBufferPointerv" )
1143                         && QGL_constructExtensionFunc( table.m_glGetBufferSubData, "glGetBufferSubData" )
1144                         && QGL_constructExtensionFunc( table.m_glGetQueryObjectiv, "glGetQueryObjectiv" )
1145                         && QGL_constructExtensionFunc( table.m_glGetQueryObjectuiv, "glGetQueryObjectuiv" )
1146                         && QGL_constructExtensionFunc( table.m_glGetQueryiv, "glGetQueryiv" )
1147                         && QGL_constructExtensionFunc( table.m_glIsBuffer, "glIsBuffer" )
1148                         && QGL_constructExtensionFunc( table.m_glIsQuery, "glIsQuery" )
1149                         && QGL_constructExtensionFunc( table.m_glMapBuffer, "glMapBuffer" )
1150                         && QGL_constructExtensionFunc( table.m_glUnmapBuffer, "glUnmapBuffer" );
1151
1152                 if ( !table.support_GL_1_5 ) {
1153                         extension_not_implemented( "GL_VERSION_1_5" );
1154                 }
1155         }
1156         else
1157         {
1158                 table.support_GL_1_5 = false;
1159         }
1160
1161
1162         if ( QGL_ExtensionSupported( "GL_ARB_vertex_program" ) ) {
1163                 table.support_ARB_vertex_program =
1164                         QGL_constructExtensionFunc( table.m_glVertexAttrib1sARB, "glVertexAttrib1sARB" )
1165                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1fARB, "glVertexAttrib1fARB" )
1166                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1dARB, "glVertexAttrib1dARB" )
1167                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2sARB, "glVertexAttrib2sARB" )
1168                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2fARB, "glVertexAttrib2fARB" )
1169                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2dARB, "glVertexAttrib2dARB" )
1170                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3sARB, "glVertexAttrib3sARB" )
1171                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3fARB, "glVertexAttrib3fARB" )
1172                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3dARB, "glVertexAttrib3dARB" )
1173                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4sARB, "glVertexAttrib4sARB" )
1174                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4fARB, "glVertexAttrib4fARB" )
1175                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4dARB, "glVertexAttrib4dARB" )
1176                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NubARB, "glVertexAttrib4NubARB" )
1177                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1svARB, "glVertexAttrib1svARB" )
1178                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1fvARB, "glVertexAttrib1fvARB" )
1179                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1dvARB, "glVertexAttrib1dvARB" )
1180                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2svARB, "glVertexAttrib2svARB" )
1181                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2fvARB, "glVertexAttrib2fvARB" )
1182                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2dvARB, "glVertexAttrib2dvARB" )
1183                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3svARB, "glVertexAttrib3svARB" )
1184                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3fvARB, "glVertexAttrib3fvARB" )
1185                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3dvARB, "glVertexAttrib3dvARB" )
1186                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4bvARB, "glVertexAttrib4bvARB" )
1187                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4svARB, "glVertexAttrib4svARB" )
1188                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4ivARB, "glVertexAttrib4ivARB" )
1189                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4ubvARB, "glVertexAttrib4ubvARB" )
1190                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4usvARB, "glVertexAttrib4usvARB" )
1191                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4uivARB, "glVertexAttrib4uivARB" )
1192                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4fvARB, "glVertexAttrib4fvARB" )
1193                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4dvARB, "glVertexAttrib4dvARB" )
1194                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NbvARB, "glVertexAttrib4NbvARB" )
1195                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NsvARB, "glVertexAttrib4NsvARB" )
1196                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NivARB, "glVertexAttrib4NivARB" )
1197                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NubvARB, "glVertexAttrib4NubvARB" )
1198                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NusvARB, "glVertexAttrib4NusvARB" )
1199                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NuivARB, "glVertexAttrib4NuivARB" )
1200                         && QGL_constructExtensionFunc( table.m_glVertexAttribPointerARB, "glVertexAttribPointerARB" )
1201                         && QGL_constructExtensionFunc( table.m_glEnableVertexAttribArrayARB, "glEnableVertexAttribArrayARB" )
1202                         && QGL_constructExtensionFunc( table.m_glDisableVertexAttribArrayARB, "glDisableVertexAttribArrayARB" )
1203                         && QGL_constructExtensionFunc( table.m_glProgramStringARB, "glProgramStringARB" )
1204                         && QGL_constructExtensionFunc( table.m_glBindProgramARB, "glBindProgramARB" )
1205                         && QGL_constructExtensionFunc( table.m_glDeleteProgramsARB, "glDeleteProgramsARB" )
1206                         && QGL_constructExtensionFunc( table.m_glGenProgramsARB, "glGenProgramsARB" )
1207                         && QGL_constructExtensionFunc( table.m_glProgramEnvParameter4dARB, "glProgramEnvParameter4dARB" )
1208                         && QGL_constructExtensionFunc( table.m_glProgramEnvParameter4dvARB, "glProgramEnvParameter4dvARB" )
1209                         && QGL_constructExtensionFunc( table.m_glProgramEnvParameter4fARB, "glProgramEnvParameter4fARB" )
1210                         && QGL_constructExtensionFunc( table.m_glProgramEnvParameter4fvARB, "glProgramEnvParameter4fvARB" )
1211                         && QGL_constructExtensionFunc( table.m_glProgramLocalParameter4dARB, "glProgramLocalParameter4dARB" )
1212                         && QGL_constructExtensionFunc( table.m_glProgramLocalParameter4dvARB, "glProgramLocalParameter4dvARB" )
1213                         && QGL_constructExtensionFunc( table.m_glProgramLocalParameter4fARB, "glProgramLocalParameter4fARB" )
1214                         && QGL_constructExtensionFunc( table.m_glProgramLocalParameter4fvARB, "glProgramLocalParameter4fvARB" )
1215                         && QGL_constructExtensionFunc( table.m_glGetProgramEnvParameterdvARB, "glGetProgramEnvParameterdvARB" )
1216                         && QGL_constructExtensionFunc( table.m_glGetProgramEnvParameterfvARB, "glGetProgramEnvParameterfvARB" )
1217                         && QGL_constructExtensionFunc( table.m_glGetProgramLocalParameterdvARB, "glGetProgramLocalParameterdvARB" )
1218                         && QGL_constructExtensionFunc( table.m_glGetProgramLocalParameterfvARB, "glGetProgramLocalParameterfvARB" )
1219                         && QGL_constructExtensionFunc( table.m_glGetProgramivARB, "glGetProgramivARB" )
1220                         && QGL_constructExtensionFunc( table.m_glGetProgramStringARB, "glGetProgramStringARB" )
1221                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribdvARB, "glGetVertexAttribdvARB" )
1222                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribfvARB, "glGetVertexAttribfvARB" )
1223                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribivARB, "glGetVertexAttribivARB" )
1224                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribPointervARB, "glGetVertexAttribPointervARB" )
1225                         && QGL_constructExtensionFunc( table.m_glIsProgramARB, "glIsProgramARB" );
1226
1227                 if ( !table.support_ARB_vertex_program ) {
1228                         extension_not_implemented( "GL_ARB_vertex_program" );
1229                 }
1230         }
1231         else
1232         {
1233                 table.support_ARB_vertex_program = false;
1234         }
1235
1236
1237         table.support_ARB_fragment_program = QGL_ExtensionSupported( "GL_ARB_fragment_program" );
1238
1239         if ( QGL_ExtensionSupported( "GL_ARB_shader_objects" ) ) {
1240                 table.support_ARB_shader_objects =
1241                         QGL_constructExtensionFunc( table.m_glDeleteObjectARB, "glDeleteObjectARB" )
1242                         && QGL_constructExtensionFunc( table.m_glGetHandleARB, "glGetHandleARB" )
1243                         && QGL_constructExtensionFunc( table.m_glDetachObjectARB, "glDetachObjectARB" )
1244                         && QGL_constructExtensionFunc( table.m_glCreateShaderObjectARB, "glCreateShaderObjectARB" )
1245                         && QGL_constructExtensionFunc( table.m_glShaderSourceARB, "glShaderSourceARB" )
1246                         && QGL_constructExtensionFunc( table.m_glCompileShaderARB, "glCompileShaderARB" )
1247                         && QGL_constructExtensionFunc( table.m_glCreateProgramObjectARB, "glCreateProgramObjectARB" )
1248                         && QGL_constructExtensionFunc( table.m_glAttachObjectARB, "glAttachObjectARB" )
1249                         && QGL_constructExtensionFunc( table.m_glLinkProgramARB, "glLinkProgramARB" )
1250                         && QGL_constructExtensionFunc( table.m_glUseProgramObjectARB, "glUseProgramObjectARB" )
1251                         && QGL_constructExtensionFunc( table.m_glValidateProgramARB, "glValidateProgramARB" )
1252                         && QGL_constructExtensionFunc( table.m_glUniform1fARB, "glUniform1fARB" )
1253                         && QGL_constructExtensionFunc( table.m_glUniform2fARB, "glUniform2fARB" )
1254                         && QGL_constructExtensionFunc( table.m_glUniform3fARB, "glUniform3fARB" )
1255                         && QGL_constructExtensionFunc( table.m_glUniform4fARB, "glUniform4fARB" )
1256                         && QGL_constructExtensionFunc( table.m_glUniform1iARB, "glUniform1iARB" )
1257                         && QGL_constructExtensionFunc( table.m_glUniform2iARB, "glUniform2iARB" )
1258                         && QGL_constructExtensionFunc( table.m_glUniform3iARB, "glUniform3iARB" )
1259                         && QGL_constructExtensionFunc( table.m_glUniform4iARB, "glUniform4iARB" )
1260                         && QGL_constructExtensionFunc( table.m_glUniform1fvARB, "glUniform1fvARB" )
1261                         && QGL_constructExtensionFunc( table.m_glUniform2fvARB, "glUniform2fvARB" )
1262                         && QGL_constructExtensionFunc( table.m_glUniform3fvARB, "glUniform3fvARB" )
1263                         && QGL_constructExtensionFunc( table.m_glUniform4fvARB, "glUniform4fvARB" )
1264                         && QGL_constructExtensionFunc( table.m_glUniform1ivARB, "glUniform1ivARB" )
1265                         && QGL_constructExtensionFunc( table.m_glUniform2ivARB, "glUniform2ivARB" )
1266                         && QGL_constructExtensionFunc( table.m_glUniform3ivARB, "glUniform3ivARB" )
1267                         && QGL_constructExtensionFunc( table.m_glUniform4ivARB, "glUniform4ivARB" )
1268                         && QGL_constructExtensionFunc( table.m_glUniformMatrix2fvARB, "glUniformMatrix2fvARB" )
1269                         && QGL_constructExtensionFunc( table.m_glUniformMatrix3fvARB, "glUniformMatrix3fvARB" )
1270                         && QGL_constructExtensionFunc( table.m_glUniformMatrix4fvARB, "glUniformMatrix4fvARB" )
1271                         && QGL_constructExtensionFunc( table.m_glGetObjectParameterfvARB, "glGetObjectParameterfvARB" )
1272                         && QGL_constructExtensionFunc( table.m_glGetObjectParameterivARB, "glGetObjectParameterivARB" )
1273                         && QGL_constructExtensionFunc( table.m_glGetInfoLogARB, "glGetInfoLogARB" )
1274                         && QGL_constructExtensionFunc( table.m_glGetAttachedObjectsARB, "glGetAttachedObjectsARB" )
1275                         && QGL_constructExtensionFunc( table.m_glGetUniformLocationARB, "glGetUniformLocationARB" )
1276                         && QGL_constructExtensionFunc( table.m_glGetActiveUniformARB, "glGetActiveUniformARB" )
1277                         && QGL_constructExtensionFunc( table.m_glGetUniformfvARB, "glGetUniformfvARB" )
1278                         && QGL_constructExtensionFunc( table.m_glGetUniformivARB, "glGetUniformivARB" )
1279                         && QGL_constructExtensionFunc( table.m_glGetShaderSourceARB, "glGetShaderSourceARB" );
1280
1281                 if ( !table.support_ARB_shader_objects ) {
1282                         extension_not_implemented( "GL_ARB_shader_objects" );
1283                 }
1284         }
1285         else
1286         {
1287                 table.support_ARB_shader_objects = false;
1288         }
1289
1290         if ( QGL_ExtensionSupported( "GL_ARB_vertex_shader" ) ) {
1291                 table.support_ARB_vertex_shader =
1292                         QGL_constructExtensionFunc( table.m_glVertexAttrib1fARB, "glVertexAttrib1fARB" )
1293                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1sARB, "glVertexAttrib1sARB" )
1294                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1dARB, "glVertexAttrib1dARB" )
1295                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2fARB, "glVertexAttrib2fARB" )
1296                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2sARB, "glVertexAttrib2sARB" )
1297                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2dARB, "glVertexAttrib2dARB" )
1298                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3fARB, "glVertexAttrib3fARB" )
1299                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3sARB, "glVertexAttrib3sARB" )
1300                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3dARB, "glVertexAttrib3dARB" )
1301                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4fARB, "glVertexAttrib4fARB" )
1302                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4sARB, "glVertexAttrib4sARB" )
1303                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4dARB, "glVertexAttrib4dARB" )
1304                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NubARB, "glVertexAttrib4NubARB" )
1305                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1fvARB, "glVertexAttrib1fvARB" )
1306                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1svARB, "glVertexAttrib1svARB" )
1307                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1dvARB, "glVertexAttrib1dvARB" )
1308                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2fvARB, "glVertexAttrib2fvARB" )
1309                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2svARB, "glVertexAttrib2svARB" )
1310                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2dvARB, "glVertexAttrib2dvARB" )
1311                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3fvARB, "glVertexAttrib3fvARB" )
1312                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3svARB, "glVertexAttrib3svARB" )
1313                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3dvARB, "glVertexAttrib3dvARB" )
1314                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4fvARB, "glVertexAttrib4fvARB" )
1315                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4svARB, "glVertexAttrib4svARB" )
1316                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4dvARB, "glVertexAttrib4dvARB" )
1317                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4ivARB, "glVertexAttrib4ivARB" )
1318                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4bvARB, "glVertexAttrib4bvARB" )
1319                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4ubvARB, "glVertexAttrib4ubvARB" )
1320                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4usvARB, "glVertexAttrib4usvARB" )
1321                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4uivARB, "glVertexAttrib4uivARB" )
1322                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NbvARB, "glVertexAttrib4NbvARB" )
1323                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NsvARB, "glVertexAttrib4NsvARB" )
1324                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NivARB, "glVertexAttrib4NivARB" )
1325                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NubvARB, "glVertexAttrib4NubvARB" )
1326                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NusvARB, "glVertexAttrib4NusvARB" )
1327                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4NuivARB, "glVertexAttrib4NuivARB" )
1328                         && QGL_constructExtensionFunc( table.m_glVertexAttribPointerARB, "glVertexAttribPointerARB" )
1329                         && QGL_constructExtensionFunc( table.m_glEnableVertexAttribArrayARB, "glEnableVertexAttribArrayARB" )
1330                         && QGL_constructExtensionFunc( table.m_glDisableVertexAttribArrayARB, "glDisableVertexAttribArrayARB" )
1331                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribdvARB, "glGetVertexAttribdvARB" )
1332                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribfvARB, "glGetVertexAttribfvARB" )
1333                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribivARB, "glGetVertexAttribivARB" )
1334                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribPointervARB, "glGetVertexAttribPointervARB" )
1335                         && QGL_constructExtensionFunc( table.m_glBindAttribLocationARB, "glBindAttribLocationARB" )
1336                         && QGL_constructExtensionFunc( table.m_glGetActiveAttribARB, "glGetActiveAttribARB" )
1337                         && QGL_constructExtensionFunc( table.m_glGetAttribLocationARB, "glGetAttribLocationARB" );
1338
1339                 if ( !table.support_ARB_vertex_shader ) {
1340                         extension_not_implemented( "GL_ARB_vertex_shader" );
1341                 }
1342         }
1343         else
1344         {
1345                 table.support_ARB_vertex_shader = false;
1346         }
1347
1348         if ( QGL_ExtensionSupported( "GL_NV_vertex_program2" ) ) {
1349                 table.support_NV_vertex_program2 =
1350                         QGL_constructExtensionFunc( table.m_glAreProgramsResidentNV, "glAreProgramsResidentNV" )
1351                         && QGL_constructExtensionFunc( table.m_glBindProgramNV, "glBindProgramNV" )
1352                         && QGL_constructExtensionFunc( table.m_glDeleteProgramsNV, "glDeleteProgramsNV" )
1353                         && QGL_constructExtensionFunc( table.m_glExecuteProgramNV, "glExecuteProgramNV" )
1354                         && QGL_constructExtensionFunc( table.m_glGenProgramsNV, "glGenProgramsNV" )
1355                         && QGL_constructExtensionFunc( table.m_glGetProgramParameterdvNV, "glGetProgramParameterdvNV" )
1356                         && QGL_constructExtensionFunc( table.m_glGetProgramParameterfvNV, "glGetProgramParameterfvNV" )
1357                         && QGL_constructExtensionFunc( table.m_glGetProgramivNV, "glGetProgramivNV" )
1358                         && QGL_constructExtensionFunc( table.m_glGetProgramStringNV, "glGetProgramStringNV" )
1359                         && QGL_constructExtensionFunc( table.m_glGetTrackMatrixivNV, "glGetTrackMatrixivNV" )
1360                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribdvNV, "glGetVertexAttribdvNV" )
1361                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribfvNV, "glGetVertexAttribfvNV" )
1362                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribivNV, "glGetVertexAttribivNV" )
1363                         && QGL_constructExtensionFunc( table.m_glGetVertexAttribPointervNV, "glGetVertexAttribPointervNV" )
1364                         && QGL_constructExtensionFunc( table.m_glIsProgramNV, "glIsProgramNV" )
1365                         && QGL_constructExtensionFunc( table.m_glLoadProgramNV, "glLoadProgramNV" )
1366                         && QGL_constructExtensionFunc( table.m_glProgramParameter4fNV, "glProgramParameter4fNV" )
1367                         && QGL_constructExtensionFunc( table.m_glProgramParameter4fvNV, "glProgramParameter4fvNV" )
1368                         && QGL_constructExtensionFunc( table.m_glProgramParameters4fvNV, "glProgramParameters4fvNV" )
1369                         && QGL_constructExtensionFunc( table.m_glRequestResidentProgramsNV, "glRequestResidentProgramsNV" )
1370                         && QGL_constructExtensionFunc( table.m_glTrackMatrixNV, "glTrackMatrixNV" )
1371                         && QGL_constructExtensionFunc( table.m_glVertexAttribPointerNV, "glVertexAttribPointerNV" )
1372                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1fNV, "glVertexAttrib1fNV" )
1373                         && QGL_constructExtensionFunc( table.m_glVertexAttrib1fvNV, "glVertexAttrib1fvNV" )
1374                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2fNV, "glVertexAttrib2fNV" )
1375                         && QGL_constructExtensionFunc( table.m_glVertexAttrib2fvNV, "glVertexAttrib2fvNV" )
1376                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3fNV, "glVertexAttrib3fNV" )
1377                         && QGL_constructExtensionFunc( table.m_glVertexAttrib3fvNV, "glVertexAttrib3fvNV" )
1378                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4fNV, "glVertexAttrib4fNV" )
1379                         && QGL_constructExtensionFunc( table.m_glVertexAttrib4fvNV, "glVertexAttrib4fvNV" )
1380                         && QGL_constructExtensionFunc( table.m_glVertexAttribs1fvNV, "glVertexAttribs1fvNV" )
1381                         && QGL_constructExtensionFunc( table.m_glVertexAttribs2fvNV, "glVertexAttribs2fvNV" )
1382                         && QGL_constructExtensionFunc( table.m_glVertexAttribs3fvNV, "glVertexAttribs3fvNV" )
1383                         && QGL_constructExtensionFunc( table.m_glVertexAttribs4fvNV, "glVertexAttribs4fvNV" );
1384
1385                 if ( !table.support_NV_vertex_program2 ) {
1386                         extension_not_implemented( "GL_NV_vertex_program2" );
1387                 }
1388         }
1389         else
1390         {
1391                 table.support_NV_vertex_program2 = false;
1392                 QGL_invalidateExtensionFunc( table.m_glAreProgramsResidentNV );
1393                 QGL_invalidateExtensionFunc( table.m_glBindProgramNV );
1394                 QGL_invalidateExtensionFunc( table.m_glDeleteProgramsNV );
1395                 QGL_invalidateExtensionFunc( table.m_glExecuteProgramNV );
1396                 QGL_invalidateExtensionFunc( table.m_glGenProgramsNV );
1397                 QGL_invalidateExtensionFunc( table.m_glGetProgramParameterdvNV );
1398                 QGL_invalidateExtensionFunc( table.m_glGetProgramParameterfvNV );
1399                 QGL_invalidateExtensionFunc( table.m_glGetProgramivNV );
1400                 QGL_invalidateExtensionFunc( table.m_glGetProgramStringNV );
1401                 QGL_invalidateExtensionFunc( table.m_glGetTrackMatrixivNV );
1402                 QGL_invalidateExtensionFunc( table.m_glGetVertexAttribdvNV );
1403                 QGL_invalidateExtensionFunc( table.m_glGetVertexAttribfvNV );
1404                 QGL_invalidateExtensionFunc( table.m_glGetVertexAttribivNV );
1405                 QGL_invalidateExtensionFunc( table.m_glGetVertexAttribPointervNV );
1406                 QGL_invalidateExtensionFunc( table.m_glIsProgramNV );
1407                 QGL_invalidateExtensionFunc( table.m_glLoadProgramNV );
1408                 QGL_invalidateExtensionFunc( table.m_glProgramParameter4fNV );
1409                 QGL_invalidateExtensionFunc( table.m_glProgramParameter4fvNV );
1410                 QGL_invalidateExtensionFunc( table.m_glProgramParameters4fvNV );
1411                 QGL_invalidateExtensionFunc( table.m_glRequestResidentProgramsNV );
1412                 QGL_invalidateExtensionFunc( table.m_glTrackMatrixNV );
1413                 QGL_invalidateExtensionFunc( table.m_glVertexAttribPointerNV );
1414                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib1fNV );
1415                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib1fvNV );
1416                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib2fNV );
1417                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib2fvNV );
1418                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib3fNV );
1419                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib3fvNV );
1420                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib4fNV );
1421                 QGL_invalidateExtensionFunc( table.m_glVertexAttrib4fvNV );
1422                 QGL_invalidateExtensionFunc( table.m_glVertexAttribs1fvNV );
1423                 QGL_invalidateExtensionFunc( table.m_glVertexAttribs2fvNV );
1424                 QGL_invalidateExtensionFunc( table.m_glVertexAttribs3fvNV );
1425                 QGL_invalidateExtensionFunc( table.m_glVertexAttribs4fvNV );
1426         }
1427
1428         if ( QGL_ExtensionSupported( "GL_NV_fragment_program" ) ) {
1429                 table.support_NV_fragment_program =
1430                         QGL_constructExtensionFunc( table.m_glProgramNamedParameter4fNV, "glProgramNamedParameter4fNV" )
1431                         && QGL_constructExtensionFunc( table.m_glProgramNamedParameter4fvNV, "glProgramNamedParameter4fvNV" )
1432                         && QGL_constructExtensionFunc( table.m_glGetProgramNamedParameterfvNV, "glGetProgramNamedParameterfvNV" );
1433
1434                 if ( !table.support_NV_fragment_program ) {
1435                         extension_not_implemented( "GL_NV_fragment_program" );
1436                 }
1437         }
1438         else
1439         {
1440                 table.support_NV_fragment_program = false;
1441         }
1442
1443         table.support_ARB_fragment_shader = QGL_ExtensionSupported( "GL_ARB_fragment_shader" );
1444         table.support_ARB_shading_language_100 = QGL_ExtensionSupported( "GL_ARB_shading_language_100" );
1445
1446         if ( QGL_ExtensionSupported( "GL_EXT_texture_filter_anisotropic" ) ) {
1447                 glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &g_maxTextureAnisotropy );
1448                 globalOutputStream() << "Anisotropic filtering possible (max " << g_maxTextureAnisotropy << "x)\n";
1449         }
1450         else
1451         {
1452                 globalOutputStream() << "No Anisotropic filtering available\n";
1453                 g_maxTextureAnisotropy = 0;
1454         }
1455 }
1456
1457 void QGL_sharedContextDestroyed( OpenGLBinding& table ){
1458         QGL_clear( table );
1459 }
1460
1461
1462 void QGL_assertNoErrors( const char *file, int line ){
1463         GLenum error = GlobalOpenGL().m_glGetError();
1464         while ( error != GL_NO_ERROR )
1465         {
1466                 const char* errorString = reinterpret_cast<const char*>( qgluErrorString( error ) );
1467                 if ( error == GL_OUT_OF_MEMORY ) {
1468                         ERROR_MESSAGE( "OpenGL out of memory error at " << file << ":" << line << ": " << errorString );
1469                 }
1470                 else
1471                 {
1472                         ERROR_MESSAGE( "OpenGL error at " << file << ":" << line << ": " << errorString );
1473                 }
1474                 error = GlobalOpenGL().m_glGetError();
1475         }
1476 }
1477
1478
1479 class QglAPI
1480 {
1481 OpenGLBinding m_qgl;
1482 public:
1483 typedef OpenGLBinding Type;
1484 STRING_CONSTANT( Name, "*" );
1485
1486 QglAPI(){
1487         QGL_Init( m_qgl );
1488
1489         m_qgl.assertNoErrors = &QGL_assertNoErrors;
1490 }
1491 ~QglAPI(){
1492         QGL_Shutdown( m_qgl );
1493 }
1494 OpenGLBinding* getTable(){
1495         return &m_qgl;
1496 }
1497 };
1498
1499 #include "modulesystem/singletonmodule.h"
1500 #include "modulesystem/moduleregistry.h"
1501
1502 typedef SingletonModule<QglAPI> QglModule;
1503 typedef Static<QglModule> StaticQglModule;
1504 StaticRegisterModule staticRegisterQgl( StaticQglModule::instance() );