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