1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.opengl.gl;
29 
30 public
31 {
32     import derelict.opengl.glfuncs;
33     import derelict.opengl.gltypes;
34 }
35 
36 private
37 {
38     import derelict.util.loader;
39     import derelict.util.exception;
40     import derelict.util.compat;
41     import derelict.opengl.extloader;
42 
43     version(Windows)
44         import derelict.opengl.wgl;
45 
46     version(darwin)
47         version = MacOSX;
48 
49     version(OSX)
50         version = MacOSX;
51 
52     version (MacOSX)
53         import derelict.opengl.cgl;
54 
55     version(linux)
56         version = GLX;
57 
58     version(FreeBSD)
59         version = freebsd;
60 
61     version(freebsd)
62         version = GLX;
63 
64     version(GLX)
65         import derelict.opengl.glx;
66 }
67 
68 enum GLVersion
69 {
70     None,
71     GL11 = 11,
72     GL12 = 12,
73     GL13 = 13,
74     GL14 = 14,
75     GL15 = 15,
76     GL20 = 20,
77     GL21 = 21,
78     MaxClassic = 21,
79 
80     GL30 = 30,
81     GL31 = 31,
82     GL32 = 32,
83     GL33 = 33,
84     GL40 = 40,
85     MaxModern = 40,
86     HighestSupported = 40
87 }
88 
89 class DerelictGLLoader : SharedLibLoader
90 {
91 private:
92     this()
93     {
94         super(
95             "opengl32.dll",
96             "libGL.so.2,libGL.so.1,libGL.so",
97             "../Frameworks/OpenGL.framework/OpenGL, /Library/Frameworks/OpenGL.framework/OpenGL, /System/Library/Frameworks/OpenGL.framework/OpenGL"
98         );
99     }
100 
101     GLVersion findMaxAvailable()
102     {
103         string verstr = toDString(glGetString(GL_VERSION));
104         if(verstr.findStr("4.0") == 0)
105             return GLVersion.GL40;
106         else if(verstr.findStr("3.3") == 0)
107             return GLVersion.GL33;
108         else if(verstr.findStr("3.2") == 0)
109             return GLVersion.GL32;
110         else if(verstr.findStr("3.1") == 0)
111             return GLVersion.GL31;
112         else if(verstr.findStr("3.0") == 0)
113             return GLVersion.GL30;
114         else if(verstr.findStr("2.1") == 0)
115             return GLVersion.GL21;
116         else if(verstr.findStr("2.0") == 0)
117             return GLVersion.GL20;
118         else if(verstr.findStr("1.5") == 0)
119             return GLVersion.GL15;
120         else if(verstr.findStr("1.4") == 0)
121             return GLVersion.GL14;
122         else if(verstr.findStr("1.3") == 0)
123             return GLVersion.GL13;
124         else if(verstr.findStr("1.2") == 0)
125             return GLVersion.GL12;
126         else if(verstr.findStr("1.1") == 0)
127             return GLVersion.GL11;
128 
129         // assume new version of OpenGL
130         // TODO this needs to be more robust -- check to make sure that there this
131         // is a valid version number and actually is higher than the highest supported
132         return GLVersion.HighestSupported;
133     }
134 
135     GLVersion _maxVersion;
136 
137 public:
138     GLVersion maxVersion()
139     {
140         return _maxVersion;
141     }
142 
143     void loadExtensions()
144     {
145         if(!hasValidContext())
146             throw new DerelictException("An OpenGL context must be created and activated before attempting to load extensions.");
147         extLoadAll();
148     }
149 
150     string[] loadedExtensionNames()
151     {
152         return getLoadedExtensionNames();
153     }
154 
155     string[] notLoadedExtensionNames()
156     {
157         return getNotLoadedExtensionNames();
158     }
159 
160     bool isExtensionSupported(string extName)
161     {
162         if(!hasValidContext())
163             throw new DerelictException("An OpenGL context must be created and activated before attempting to check for supported extensions.");
164 
165         return extIsSupported(extName);
166     }
167 
168     bool isExtensionLoaded(string extName)
169     {
170         if(!hasValidContext())
171             throw new DerelictException("An OpenGL context must be created and activated, and extensions must be loaded, before checking for loaded extensions.");
172 
173         return (GLExtensionState.Loaded == extGetState(extName));
174     }
175 
176     GLExtensionState getExtensionState(string extName)
177     {
178         if(!hasValidContext())
179             throw new DerelictException("An OpenGL context must be created and activated, and extensions must be loaded, before chacking extension state.");
180 
181         return extGetState(extName);
182     }
183 
184     alias loadClassicVersions loadExtendedVersions;
185 
186     GLVersion loadClassicVersions(GLVersion targetVersion = GLVersion.GL11)
187     {
188         if(!hasValidContext())
189             throw new DerelictException("An OpenGL context must be created and activated before attempting to load extended versions.");
190 
191         GLVersion maxAvail = findMaxAvailable();
192         if(maxAvail < targetVersion)
193             throw new DerelictException("Required GL version " ~ versionToString(targetVersion) ~ " is not available.");
194 
195         bool doThrow = false;
196 
197         // gl 1.2
198         if(maxAvail >= GLVersion.GL12)
199         {
200             doThrow = (targetVersion >= GLVersion.GL12);
201 
202             bindExtendedFunc(cast(void**)&glDrawRangeElements, "glDrawRangeElements", doThrow);
203             bindExtendedFunc(cast(void**)&glTexImage3D, "glTexImage3D", doThrow);
204             bindExtendedFunc(cast(void**)&glTexSubImage3D, "glTexSubImage3D", doThrow);
205             bindExtendedFunc(cast(void**)&glCopyTexSubImage3D, "glCopyTexSubImage3D", doThrow);
206 
207             /* GL_ARB_imaging
208             bindExtendedFunc(cast(void**)&glColorTable, "glColorTable", doThrow);
209             bindExtendedFunc(cast(void**)&glColorSubTable, "glColorSubTable", doThrow);
210             bindExtendedFunc(cast(void**)&glColorTableParameteriv, "glColorTableParameteriv", doThrow);
211             bindExtendedFunc(cast(void**)&glColorTableParameterfv, "glColorTableParameterfv", doThrow);
212             bindExtendedFunc(cast(void**)&glCopyColorSubTable, "glCopyColorSubTable", doThrow);
213             bindExtendedFunc(cast(void**)&glCopyColorTable, "glCopyColorTable", doThrow);
214             bindExtendedFunc(cast(void**)&glGetColorTable, "glGetColorTable", doThrow);
215             bindExtendedFunc(cast(void**)&glGetColorTableParameterfv, "glGetColorTableParameterfv", doThrow);
216             bindExtendedFunc(cast(void**)&glGetColorTableParameteriv, "glGetColorTableParameteriv", doThrow);
217             bindExtendedFunc(cast(void**)&glHistogram, "glHistogram", doThrow);
218             bindExtendedFunc(cast(void**)&glResetHistogram, "glResetHistogram", doThrow);
219             bindExtendedFunc(cast(void**)&glGetHistogram, "glGetHistogram", doThrow);
220             bindExtendedFunc(cast(void**)&glGetHistogramParameterfv, "glGetHistogramParameterfv", doThrow);
221             bindExtendedFunc(cast(void**)&glGetHistogramParameteriv, "glGetHistogramParameteriv", doThrow);
222             bindExtendedFunc(cast(void**)&glMinmax, "glMinmax", doThrow);
223             bindExtendedFunc(cast(void**)&glResetMinmax, "glResetMinmax", doThrow);
224             bindExtendedFunc(cast(void**)&glGetMinmax, "glGetMinmax", doThrow);
225             bindExtendedFunc(cast(void**)&glGetMinmaxParameterfv, "glGetMinmaxParameterfv", doThrow);
226             bindExtendedFunc(cast(void**)&glGetMinmaxParameteriv, "glGetMinmaxParameteriv", doThrow);
227             bindExtendedFunc(cast(void**)&glConvolutionFilter1D, "glConvolutionFilter1D", doThrow);
228             bindExtendedFunc(cast(void**)&glConvolutionFilter2D, "glConvolutionFilter2D", doThrow);
229             bindExtendedFunc(cast(void**)&glConvolutionParameterf, "glConvolutionParameterf", doThrow);
230             bindExtendedFunc(cast(void**)&glConvolutionParameterfv, "glConvolutionParameterfv", doThrow);
231             bindExtendedFunc(cast(void**)&glConvolutionParameteri, "glConvolutionParameteri", doThrow);
232             bindExtendedFunc(cast(void**)&glConvolutionParameteriv, "glConvolutionParameteriv", doThrow);
233             bindExtendedFunc(cast(void**)&glCopyConvolutionFilter1D, "glCopyConvolutionFilter1D", doThrow);
234             bindExtendedFunc(cast(void**)&glCopyConvolutionFilter2D, "glCopyConvolutionFilter2D", doThrow);
235             bindExtendedFunc(cast(void**)&glGetConvolutionFilter, "glGetConvolutionFilter", doThrow);
236             bindExtendedFunc(cast(void**)&glGetConvolutionParameterfv, "glGetConvolutionParameterfv", doThrow);
237             bindExtendedFunc(cast(void**)&glGetConvolutionParameteriv, "glGetConvolutionParameteriv", doThrow);
238             bindExtendedFunc(cast(void**)&glSeparableFilter2D, "glSeparableFilter2D", doThrow);
239             bindExtendedFunc(cast(void**)&glGetSeparableFilter, "glGetSeparableFilter", doThrow);
240             */
241             _maxVersion = GLVersion.GL12;
242         }
243 
244         // gl 1.3
245         if(maxAvail >= GLVersion.GL13)
246         {
247             doThrow = (targetVersion >= GLVersion.GL13);
248 
249             bindExtendedFunc(cast(void**)&glActiveTexture, "glActiveTexture", doThrow);
250             bindExtendedFunc(cast(void**)&glClientActiveTexture, "glClientActiveTexture", doThrow);
251             bindExtendedFunc(cast(void**)&glMultiTexCoord1d, "glMultiTexCoord1d", doThrow);
252             bindExtendedFunc(cast(void**)&glMultiTexCoord1dv, "glMultiTexCoord1dv", doThrow);
253             bindExtendedFunc(cast(void**)&glMultiTexCoord1f, "glMultiTexCoord1f", doThrow);
254             bindExtendedFunc(cast(void**)&glMultiTexCoord1fv, "glMultiTexCoord1fv", doThrow);
255             bindExtendedFunc(cast(void**)&glMultiTexCoord1i, "glMultiTexCoord1i", doThrow);
256             bindExtendedFunc(cast(void**)&glMultiTexCoord1iv, "glMultiTexCoord1iv", doThrow);
257             bindExtendedFunc(cast(void**)&glMultiTexCoord1s, "glMultiTexCoord1s", doThrow);
258             bindExtendedFunc(cast(void**)&glMultiTexCoord1sv, "glMultiTexCoord1sv", doThrow);
259             bindExtendedFunc(cast(void**)&glMultiTexCoord2d, "glMultiTexCoord2d", doThrow);
260             bindExtendedFunc(cast(void**)&glMultiTexCoord2dv, "glMultiTexCoord2dv", doThrow);
261             bindExtendedFunc(cast(void**)&glMultiTexCoord2f, "glMultiTexCoord2f", doThrow);
262             bindExtendedFunc(cast(void**)&glMultiTexCoord2fv, "glMultiTexCoord2fv", doThrow);
263             bindExtendedFunc(cast(void**)&glMultiTexCoord2i, "glMultiTexCoord2i", doThrow);
264             bindExtendedFunc(cast(void**)&glMultiTexCoord2iv, "glMultiTexCoord2iv", doThrow);
265             bindExtendedFunc(cast(void**)&glMultiTexCoord2s, "glMultiTexCoord2s", doThrow);
266             bindExtendedFunc(cast(void**)&glMultiTexCoord2sv, "glMultiTexCoord2sv", doThrow);
267             bindExtendedFunc(cast(void**)&glMultiTexCoord3d, "glMultiTexCoord3d", doThrow);
268             bindExtendedFunc(cast(void**)&glMultiTexCoord3dv, "glMultiTexCoord3d", doThrow);
269             bindExtendedFunc(cast(void**)&glMultiTexCoord3f, "glMultiTexCoord3f", doThrow);
270             bindExtendedFunc(cast(void**)&glMultiTexCoord3fv, "glMultiTexCoord3fv", doThrow);
271             bindExtendedFunc(cast(void**)&glMultiTexCoord3i, "glMultiTexCoord3i", doThrow);
272             bindExtendedFunc(cast(void**)&glMultiTexCoord3iv, "glMultiTexCoord3iv", doThrow);
273             bindExtendedFunc(cast(void**)&glMultiTexCoord3s, "glMultiTexCoord3s", doThrow);
274             bindExtendedFunc(cast(void**)&glMultiTexCoord3sv, "glMultiTexCoord3sv", doThrow);
275             bindExtendedFunc(cast(void**)&glMultiTexCoord4d, "glMultiTexCoord4d", doThrow);
276             bindExtendedFunc(cast(void**)&glMultiTexCoord4dv, "glMultiTexCoord4dv", doThrow);
277             bindExtendedFunc(cast(void**)&glMultiTexCoord4f, "glMultiTexCoord4f", doThrow);
278             bindExtendedFunc(cast(void**)&glMultiTexCoord4fv, "glMultiTexCoord4fv", doThrow);
279             bindExtendedFunc(cast(void**)&glMultiTexCoord4i, "glMultiTexCoord4i", doThrow);
280             bindExtendedFunc(cast(void**)&glMultiTexCoord4iv, "glMultiTexCoord4iv", doThrow);
281             bindExtendedFunc(cast(void**)&glMultiTexCoord4s, "glMultiTexCoord4s", doThrow);
282             bindExtendedFunc(cast(void**)&glMultiTexCoord4sv, "glMultiTexCoord4sv", doThrow);
283             bindExtendedFunc(cast(void**)&glLoadTransposeMatrixd, "glLoadTransposeMatrixd", doThrow);
284             bindExtendedFunc(cast(void**)&glLoadTransposeMatrixf, "glLoadTransposeMatrixf", doThrow);
285             bindExtendedFunc(cast(void**)&glMultTransposeMatrixd, "glMultTransposeMatrixd", doThrow);
286             bindExtendedFunc(cast(void**)&glMultTransposeMatrixf, "glMultTransposeMatrixf", doThrow);
287             bindExtendedFunc(cast(void**)&glSampleCoverage, "glSampleCoverage", doThrow);
288             bindExtendedFunc(cast(void**)&glCompressedTexImage1D, "glCompressedTexImage1D", doThrow);
289             bindExtendedFunc(cast(void**)&glCompressedTexImage2D, "glCompressedTexImage2D", doThrow);
290             bindExtendedFunc(cast(void**)&glCompressedTexImage3D, "glCompressedTexImage3D", doThrow);
291             bindExtendedFunc(cast(void**)&glCompressedTexSubImage1D, "glCompressedTexSubImage1D", doThrow);
292             bindExtendedFunc(cast(void**)&glCompressedTexSubImage2D, "glCompressedTexSubImage2D", doThrow);
293             bindExtendedFunc(cast(void**)&glCompressedTexSubImage3D, "glCompressedTexSubImage3D", doThrow);
294             bindExtendedFunc(cast(void**)&glGetCompressedTexImage, "glGetCompressedTexImage", doThrow);
295 
296             _maxVersion = GLVersion.GL13;
297         }
298 
299         if(maxAvail >= GLVersion.GL14)
300         {
301             doThrow = (targetVersion >= GLVersion.GL14);
302 
303             bindExtendedFunc(cast(void**)&glBlendFuncSeparate, "glBlendFuncSeparate", doThrow);
304             bindExtendedFunc(cast(void**)&glFogCoordf, "glFogCoordf", doThrow);
305             bindExtendedFunc(cast(void**)&glFogCoordfv, "glFogCoordfv", doThrow);
306             bindExtendedFunc(cast(void**)&glFogCoordd, "glFogCoordd", doThrow);
307             bindExtendedFunc(cast(void**)&glFogCoorddv, "glFogCoorddv", doThrow);
308             bindExtendedFunc(cast(void**)&glFogCoordPointer, "glFogCoordPointer", doThrow);
309             bindExtendedFunc(cast(void**)&glMultiDrawArrays, "glMultiDrawArrays", doThrow);
310             bindExtendedFunc(cast(void**)&glMultiDrawElements, "glMultiDrawElements", doThrow);
311             bindExtendedFunc(cast(void**)&glPointParameterf, "glPointParameterf", doThrow);
312             bindExtendedFunc(cast(void**)&glPointParameterfv, "glPointParameterfv", doThrow);
313             bindExtendedFunc(cast(void**)&glPointParameteri, "glPointParameteri", doThrow);
314             bindExtendedFunc(cast(void**)&glPointParameteriv, "glPointParameteriv", doThrow);
315             bindExtendedFunc(cast(void**)&glSecondaryColor3b, "glSecondaryColor3b", doThrow);
316             bindExtendedFunc(cast(void**)&glSecondaryColor3bv, "glSecondaryColor3bv", doThrow);
317             bindExtendedFunc(cast(void**)&glSecondaryColor3d, "glSecondaryColor3d", doThrow);
318             bindExtendedFunc(cast(void**)&glSecondaryColor3dv, "glSecondaryColor3dv", doThrow);
319             bindExtendedFunc(cast(void**)&glSecondaryColor3f, "glSecondaryColor3f", doThrow);
320             bindExtendedFunc(cast(void**)&glSecondaryColor3fv, "glSecondaryColor3fv", doThrow);
321             bindExtendedFunc(cast(void**)&glSecondaryColor3i, "glSecondaryColor3i", doThrow);
322             bindExtendedFunc(cast(void**)&glSecondaryColor3iv, "glSecondaryColor3iv", doThrow);
323             bindExtendedFunc(cast(void**)&glSecondaryColor3s, "glSecondaryColor3s", doThrow);
324             bindExtendedFunc(cast(void**)&glSecondaryColor3sv, "glSecondaryColor3sv", doThrow);
325             bindExtendedFunc(cast(void**)&glSecondaryColor3ub, "glSecondaryColor3ub", doThrow);
326             bindExtendedFunc(cast(void**)&glSecondaryColor3ubv, "glSecondaryColor3ubv", doThrow);
327             bindExtendedFunc(cast(void**)&glSecondaryColor3ui, "glSecondaryColor3ui", doThrow);
328             bindExtendedFunc(cast(void**)&glSecondaryColor3uiv, "glSecondaryColor3uiv", doThrow);
329             bindExtendedFunc(cast(void**)&glSecondaryColor3us, "glSecondaryColor3us", doThrow);
330             bindExtendedFunc(cast(void**)&glSecondaryColor3usv, "glSecondaryColor3usv", doThrow);
331             bindExtendedFunc(cast(void**)&glSecondaryColorPointer, "glSecondaryColorPointer", doThrow);
332             bindExtendedFunc(cast(void**)&glWindowPos2d, "glWindowPos2d", doThrow);
333             bindExtendedFunc(cast(void**)&glWindowPos2dv, "glWindowPos2dv", doThrow);
334             bindExtendedFunc(cast(void**)&glWindowPos2f, "glWindowPos2f", doThrow);
335             bindExtendedFunc(cast(void**)&glWindowPos2fv, "glWindowPos2fv", doThrow);
336             bindExtendedFunc(cast(void**)&glWindowPos2i, "glWindowPos2i", doThrow);
337             bindExtendedFunc(cast(void**)&glWindowPos2iv, "glWindowPos2iv", doThrow);
338             bindExtendedFunc(cast(void**)&glWindowPos2s, "glWindowPos2s", doThrow);
339             bindExtendedFunc(cast(void**)&glWindowPos2sv, "glWindowPos2sv", doThrow);
340             bindExtendedFunc(cast(void**)&glWindowPos3d, "glWindowPos3d", doThrow);
341             bindExtendedFunc(cast(void**)&glWindowPos3dv, "glWindowPos3dv", doThrow);
342             bindExtendedFunc(cast(void**)&glWindowPos3f, "glWindowPos3f", doThrow);
343             bindExtendedFunc(cast(void**)&glWindowPos3fv, "glWindowPos3fv", doThrow);
344             bindExtendedFunc(cast(void**)&glWindowPos3i, "glWindowPos3i", doThrow);
345             bindExtendedFunc(cast(void**)&glWindowPos3iv, "glWindowPos3iv", doThrow);
346             bindExtendedFunc(cast(void**)&glWindowPos3s, "glWindowPos3s", doThrow);
347             bindExtendedFunc(cast(void**)&glWindowPos3sv, "glWindowPos3sv", doThrow);
348             bindExtendedFunc(cast(void**)&glBlendEquation, "glBlendEquation", doThrow);
349             bindExtendedFunc(cast(void**)&glBlendColor, "glBlendColor", doThrow);
350 
351             _maxVersion = GLVersion.GL14;
352         }
353 
354         if(maxAvail >= GLVersion.GL15)
355         {
356             doThrow = (targetVersion >= GLVersion.GL15);
357 
358             bindExtendedFunc(cast(void**)&glGenQueries, "glGenQueries", doThrow);
359             bindExtendedFunc(cast(void**)&glDeleteQueries, "glDeleteQueries", doThrow);
360             bindExtendedFunc(cast(void**)&glIsQuery, "glIsQuery", doThrow);
361             bindExtendedFunc(cast(void**)&glBeginQuery, "glBeginQuery", doThrow);
362             bindExtendedFunc(cast(void**)&glEndQuery, "glEndQuery", doThrow);
363             bindExtendedFunc(cast(void**)&glGetQueryiv, "glGetQueryiv", doThrow);
364             bindExtendedFunc(cast(void**)&glGetQueryObjectiv, "glGetQueryObjectiv", doThrow);
365             bindExtendedFunc(cast(void**)&glGetQueryObjectuiv, "glGetQueryObjectuiv", doThrow);
366             bindExtendedFunc(cast(void**)&glBindBuffer, "glBindBuffer", doThrow);
367             bindExtendedFunc(cast(void**)&glDeleteBuffers, "glDeleteBuffers", doThrow);
368             bindExtendedFunc(cast(void**)&glGenBuffers, "glGenBuffers", doThrow);
369             bindExtendedFunc(cast(void**)&glIsBuffer, "glIsBuffer", doThrow);
370             bindExtendedFunc(cast(void**)&glBufferData, "glBufferData", doThrow);
371             bindExtendedFunc(cast(void**)&glBufferSubData, "glBufferSubData", doThrow);
372             bindExtendedFunc(cast(void**)&glGetBufferSubData, "glGetBufferSubData", doThrow);
373             bindExtendedFunc(cast(void**)&glMapBuffer, "glMapBuffer", doThrow);
374             bindExtendedFunc(cast(void**)&glUnmapBuffer, "glUnmapBuffer", doThrow);
375             bindExtendedFunc(cast(void**)&glGetBufferParameteriv, "glGetBufferParameteriv", doThrow);
376             bindExtendedFunc(cast(void**)&glGetBufferPointerv, "glGetBufferPointerv", doThrow);
377 
378             _maxVersion = GLVersion.GL15;
379         }
380 
381         if(maxAvail >= GLVersion.GL20)
382         {
383             doThrow = (targetVersion >= GLVersion.GL20);
384 
385             bindExtendedFunc(cast(void**)&glBlendEquationSeparate, "glBlendEquationSeparate", doThrow);
386             bindExtendedFunc(cast(void**)&glDrawBuffers, "glDrawBuffers", doThrow);
387             bindExtendedFunc(cast(void**)&glStencilOpSeparate, "glStencilOpSeparate", doThrow);
388             bindExtendedFunc(cast(void**)&glStencilFuncSeparate, "glStencilFuncSeparate", doThrow);
389             bindExtendedFunc(cast(void**)&glStencilMaskSeparate, "glStencilMaskSeparate", doThrow);
390             bindExtendedFunc(cast(void**)&glAttachShader, "glAttachShader", doThrow);
391             bindExtendedFunc(cast(void**)&glBindAttribLocation, "glBindAttribLocation", doThrow);
392             bindExtendedFunc(cast(void**)&glCompileShader, "glCompileShader", doThrow);
393             bindExtendedFunc(cast(void**)&glCreateProgram, "glCreateProgram", doThrow);
394             bindExtendedFunc(cast(void**)&glCreateShader, "glCreateShader", doThrow);
395             bindExtendedFunc(cast(void**)&glDeleteProgram, "glDeleteProgram", doThrow);
396             bindExtendedFunc(cast(void**)&glDeleteShader, "glDeleteShader", doThrow);
397             bindExtendedFunc(cast(void**)&glDetachShader, "glDetachShader", doThrow);
398             bindExtendedFunc(cast(void**)&glDisableVertexAttribArray, "glDisableVertexAttribArray", doThrow);
399             bindExtendedFunc(cast(void**)&glEnableVertexAttribArray, "glEnableVertexAttribArray", doThrow);
400             bindExtendedFunc(cast(void**)&glGetActiveAttrib, "glGetActiveAttrib", doThrow);
401             bindExtendedFunc(cast(void**)&glGetActiveUniform, "glGetActiveUniform", doThrow);
402             bindExtendedFunc(cast(void**)&glGetAttachedShaders, "glGetAttachedShaders", doThrow);
403             bindExtendedFunc(cast(void**)&glGetAttribLocation, "glGetAttribLocation", doThrow);
404             bindExtendedFunc(cast(void**)&glGetProgramiv, "glGetProgramiv", doThrow);
405             bindExtendedFunc(cast(void**)&glGetProgramInfoLog, "glGetProgramInfoLog", doThrow);
406             bindExtendedFunc(cast(void**)&glGetShaderiv, "glGetShaderiv", doThrow);
407             bindExtendedFunc(cast(void**)&glGetShaderInfoLog, "glGetShaderInfoLog", doThrow);
408             bindExtendedFunc(cast(void**)&glGetShaderSource, "glGetShaderSource", doThrow);
409             bindExtendedFunc(cast(void**)&glGetUniformLocation, "glGetUniformLocation", doThrow);
410             bindExtendedFunc(cast(void**)&glGetUniformfv, "glGetUniformfv", doThrow);
411             bindExtendedFunc(cast(void**)&glGetUniformiv, "glGetUniformiv", doThrow);
412             bindExtendedFunc(cast(void**)&glGetVertexAttribdv, "glGetVertexAttribdv", doThrow);
413             bindExtendedFunc(cast(void**)&glGetVertexAttribfv, "glGetVertexAttribfv", doThrow);
414             bindExtendedFunc(cast(void**)&glGetVertexAttribiv, "glGetVertexAttribiv", doThrow);
415             bindExtendedFunc(cast(void**)&glGetVertexAttribPointerv, "glGetVertexAttribPointerv", doThrow);
416             bindExtendedFunc(cast(void**)&glIsProgram, "glIsProgram", doThrow);
417             bindExtendedFunc(cast(void**)&glIsShader, "glIsShader", doThrow);
418             bindExtendedFunc(cast(void**)&glLinkProgram, "glLinkProgram", doThrow);
419             bindExtendedFunc(cast(void**)&glShaderSource, "glShaderSource", doThrow);
420             bindExtendedFunc(cast(void**)&glUseProgram, "glUseProgram", doThrow);
421             bindExtendedFunc(cast(void**)&glUniform1f, "glUniform1f", doThrow);
422             bindExtendedFunc(cast(void**)&glUniform2f, "glUniform2f", doThrow);
423             bindExtendedFunc(cast(void**)&glUniform3f, "glUniform3f", doThrow);
424             bindExtendedFunc(cast(void**)&glUniform4f, "glUniform4f", doThrow);
425             bindExtendedFunc(cast(void**)&glUniform1i, "glUniform1i", doThrow);
426             bindExtendedFunc(cast(void**)&glUniform2i, "glUniform2i", doThrow);
427             bindExtendedFunc(cast(void**)&glUniform3i, "glUniform3i", doThrow);
428             bindExtendedFunc(cast(void**)&glUniform4i, "glUniform4i", doThrow);
429             bindExtendedFunc(cast(void**)&glUniform1fv, "glUniform1fv", doThrow);
430             bindExtendedFunc(cast(void**)&glUniform2fv, "glUniform2fv", doThrow);
431             bindExtendedFunc(cast(void**)&glUniform3fv, "glUniform3fv", doThrow);
432             bindExtendedFunc(cast(void**)&glUniform4fv, "glUniform4fv", doThrow);
433             bindExtendedFunc(cast(void**)&glUniform1iv, "glUniform1iv", doThrow);
434             bindExtendedFunc(cast(void**)&glUniform2iv, "glUniform2iv", doThrow);
435             bindExtendedFunc(cast(void**)&glUniform3iv, "glUniform3iv", doThrow);
436             bindExtendedFunc(cast(void**)&glUniform4iv, "glUniform4iv", doThrow);
437             bindExtendedFunc(cast(void**)&glUniformMatrix2fv, "glUniformMatrix2fv", doThrow);
438             bindExtendedFunc(cast(void**)&glUniformMatrix3fv, "glUniformMatrix3fv", doThrow);
439             bindExtendedFunc(cast(void**)&glUniformMatrix4fv, "glUniformMatrix4fv", doThrow);
440             bindExtendedFunc(cast(void**)&glValidateProgram, "glValidateProgram", doThrow);
441             bindExtendedFunc(cast(void**)&glVertexAttrib1d, "glVertexAttrib1d", doThrow);
442             bindExtendedFunc(cast(void**)&glVertexAttrib1dv, "glVertexAttrib1dv", doThrow);
443             bindExtendedFunc(cast(void**)&glVertexAttrib1f, "glVertexAttrib1f", doThrow);
444             bindExtendedFunc(cast(void**)&glVertexAttrib1fv, "glVertexAttrib1fv", doThrow);
445             bindExtendedFunc(cast(void**)&glVertexAttrib1s, "glVertexAttrib1s", doThrow);
446             bindExtendedFunc(cast(void**)&glVertexAttrib1sv, "glVertexAttrib1sv", doThrow);
447             bindExtendedFunc(cast(void**)&glVertexAttrib2d, "glVertexAttrib2d", doThrow);
448             bindExtendedFunc(cast(void**)&glVertexAttrib2dv, "glVertexAttrib2dv", doThrow);
449             bindExtendedFunc(cast(void**)&glVertexAttrib2f, "glVertexAttrib2f", doThrow);
450             bindExtendedFunc(cast(void**)&glVertexAttrib2fv, "glVertexAttrib2fv", doThrow);
451             bindExtendedFunc(cast(void**)&glVertexAttrib2s, "glVertexAttrib2s", doThrow);
452             bindExtendedFunc(cast(void**)&glVertexAttrib2sv, "glVertexAttrib2sv", doThrow);
453             bindExtendedFunc(cast(void**)&glVertexAttrib3d, "glVertexAttrib3d", doThrow);
454             bindExtendedFunc(cast(void**)&glVertexAttrib3dv, "glVertexAttrib3dv", doThrow);
455             bindExtendedFunc(cast(void**)&glVertexAttrib3f, "glVertexAttrib3f", doThrow);
456             bindExtendedFunc(cast(void**)&glVertexAttrib3fv, "glVertexAttrib3fv", doThrow);
457             bindExtendedFunc(cast(void**)&glVertexAttrib3s, "glVertexAttrib3s", doThrow);
458             bindExtendedFunc(cast(void**)&glVertexAttrib3sv, "glVertexAttrib3sv", doThrow);
459             bindExtendedFunc(cast(void**)&glVertexAttrib4Nbv, "glVertexAttrib4Nbv", doThrow);
460             bindExtendedFunc(cast(void**)&glVertexAttrib4Niv, "glVertexAttrib4Niv", doThrow);
461             bindExtendedFunc(cast(void**)&glVertexAttrib4Nsv, "glVertexAttrib4Nsv", doThrow);
462             bindExtendedFunc(cast(void**)&glVertexAttrib4Nub, "glVertexAttrib4Nub", doThrow);
463             bindExtendedFunc(cast(void**)&glVertexAttrib4Nubv, "glVertexAttrib4Nubv", doThrow);
464             bindExtendedFunc(cast(void**)&glVertexAttrib4Nuiv, "glVertexAttrib4Nuiv", doThrow);
465             bindExtendedFunc(cast(void**)&glVertexAttrib4Nusv, "glVertexAttrib4Nusv", doThrow);
466             bindExtendedFunc(cast(void**)&glVertexAttrib4bv, "glVertexAttrib4bv", doThrow);
467             bindExtendedFunc(cast(void**)&glVertexAttrib4d, "glVertexAttrib4d", doThrow);
468             bindExtendedFunc(cast(void**)&glVertexAttrib4dv, "glVertexAttrib4dv", doThrow);
469             bindExtendedFunc(cast(void**)&glVertexAttrib4f, "glVertexAttrib4f", doThrow);
470             bindExtendedFunc(cast(void**)&glVertexAttrib4fv, "glVertexAttrib4fv", doThrow);
471             bindExtendedFunc(cast(void**)&glVertexAttrib4iv, "glVertexAttrib4iv", doThrow);
472             bindExtendedFunc(cast(void**)&glVertexAttrib4s, "glVertexAttrib4s", doThrow);
473             bindExtendedFunc(cast(void**)&glVertexAttrib4sv, "glVertexAttrib4sv", doThrow);
474             bindExtendedFunc(cast(void**)&glVertexAttrib4ubv, "glVertexAttrib4ubv", doThrow);
475             bindExtendedFunc(cast(void**)&glVertexAttrib4uiv, "glVertexAttrib4uiv", doThrow);
476             bindExtendedFunc(cast(void**)&glVertexAttrib4usv, "glVertexAttrib4usv", doThrow);
477             bindExtendedFunc(cast(void**)&glVertexAttribPointer, "glVertexAttribPointer", doThrow);
478 
479             _maxVersion = GLVersion.GL20;
480         }
481 
482         if(maxAvail >= GLVersion.GL21)
483         {
484             doThrow = (targetVersion >= GLVersion.GL21);
485 
486             bindExtendedFunc(cast(void**)&glUniformMatrix2x3fv, "glUniformMatrix2x3fv", doThrow);
487             bindExtendedFunc(cast(void**)&glUniformMatrix3x2fv, "glUniformMatrix3x2fv", doThrow);
488             bindExtendedFunc(cast(void**)&glUniformMatrix2x4fv, "glUniformMatrix2x4fv", doThrow);
489             bindExtendedFunc(cast(void**)&glUniformMatrix4x2fv, "glUniformMatrix4x2fv", doThrow);
490             bindExtendedFunc(cast(void**)&glUniformMatrix3x4fv, "glUniformMatrix3x4fv", doThrow);
491             bindExtendedFunc(cast(void**)&glUniformMatrix4x3fv, "glUniformMatrix4x3fv", doThrow);
492 
493             _maxVersion = GLVersion.GL21;
494         }
495 
496         return _maxVersion;
497     }
498 
499     GLVersion loadModernVersions(GLVersion targetVersion = GLVersion.GL30)
500     {
501         if(!hasValidContext())
502             throw new DerelictException("An OpenGL context must be created and activated before attempting to load modern versions.");
503 
504         GLVersion maxAvail = findMaxAvailable();
505         if(maxAvail < targetVersion)
506             throw new DerelictException("Required GL version " ~ versionToString(targetVersion) ~ " is not available.");
507 
508         bool doThrow = false;
509 
510         // gl 3.0
511         if(maxAvail >= GLVersion.GL30)
512         {
513             doThrow = (targetVersion >= GLVersion.GL30);
514             bindExtendedFunc(cast(void**)&glBeginConditionalRender, "glBeginConditionalRender", doThrow);
515             bindExtendedFunc(cast(void**)&glBeginTransformFeedback, "glBeginTransformFeedback", doThrow);
516             bindExtendedFunc(cast(void**)&glBindFragDataLocation, "glBindFragDataLocation", doThrow);
517             bindExtendedFunc(cast(void**)&glClampColor, "glClampColor", doThrow);
518             bindExtendedFunc(cast(void**)&glClearBufferfi, "glClearBufferfi", doThrow);
519             bindExtendedFunc(cast(void**)&glClearBufferfv, "glClearBufferfv", doThrow);
520             bindExtendedFunc(cast(void**)&glClearBufferiv, "glClearBufferiv", doThrow);
521             bindExtendedFunc(cast(void**)&glClearBufferuiv, "glClearBufferuiv", doThrow);
522             bindExtendedFunc(cast(void**)&glColorMaski, "glColorMaski", doThrow);
523             bindExtendedFunc(cast(void**)&glDisablei, "glDisablei", doThrow);
524             bindExtendedFunc(cast(void**)&glEnablei, "glEnablei", doThrow);
525             bindExtendedFunc(cast(void**)&glEndConditionalRender, "glEndConditionalRender", doThrow);
526             bindExtendedFunc(cast(void**)&glEndTransformFeedback, "glEndTransformFeedback", doThrow);
527             bindExtendedFunc(cast(void**)&glBindBufferRange, "glBindBufferRange", doThrow);
528             bindExtendedFunc(cast(void**)&glBindBufferBase, "glBindBufferBase", doThrow);
529             bindExtendedFunc(cast(void**)&glGetBooleani_v, "glGetBooleani_v", doThrow);
530             bindExtendedFunc(cast(void**)&glGetIntegeri_v, "glGetIntegeri_v", doThrow);
531             bindExtendedFunc(cast(void**)&glGetFragDataLocation, "glGetFragDataLocation", doThrow);
532             bindExtendedFunc(cast(void**)&glGetStringi, "glGetStringi", doThrow);
533             bindExtendedFunc(cast(void**)&glGetTexParameterIiv, "glGetTexParameterIiv", doThrow);
534             bindExtendedFunc(cast(void**)&glGetTexParameterIuiv, "glGetTexParameterIuiv", doThrow);
535             bindExtendedFunc(cast(void**)&glIsEnabledi, "glIsEnabledi", doThrow);
536             bindExtendedFunc(cast(void**)&glTexParameterIiv, "glTexParameterIiv", doThrow);
537             bindExtendedFunc(cast(void**)&glTexParameterIuiv, "glTexParameterIuiv", doThrow);
538             bindExtendedFunc(cast(void**)&glTransformFeedbackVaryings, "glTransformFeedbackVaryings", doThrow);
539             bindExtendedFunc(cast(void**)&glGetTransformFeedbackVarying, "glGetTransformFeedbackVarying", doThrow);
540             bindExtendedFunc(cast(void**)&glUniform1ui, "glUniform1ui", doThrow);
541             bindExtendedFunc(cast(void**)&glUniform1uiv, "glUniform1uiv", doThrow);
542             bindExtendedFunc(cast(void**)&glUniform2ui, "glUniform2ui", doThrow);
543             bindExtendedFunc(cast(void**)&glUniform2uiv, "glUniform2uiv", doThrow);
544             bindExtendedFunc(cast(void**)&glUniform3ui, "glUniform3ui", doThrow);
545             bindExtendedFunc(cast(void**)&glUniform3uiv, "glUniform3uiv", doThrow);
546             bindExtendedFunc(cast(void**)&glUniform4ui, "glUniform4ui", doThrow);
547             bindExtendedFunc(cast(void**)&glUniform4uiv, "glUniform4uiv", doThrow);
548             bindExtendedFunc(cast(void**)&glVertexAttribI1i, "glVertexAttribI1i", doThrow);
549             bindExtendedFunc(cast(void**)&glVertexAttribI1iv, "glVertexAttribI1iv", doThrow);
550             bindExtendedFunc(cast(void**)&glVertexAttribI1ui, "glVertexAttribI1ui", doThrow);
551             bindExtendedFunc(cast(void**)&glVertexAttribI1uiv, "glVertexAttribI1uiv", doThrow);
552             bindExtendedFunc(cast(void**)&glVertexAttribI2i, "glVertexAttribI2i", doThrow);
553             bindExtendedFunc(cast(void**)&glVertexAttribI2iv, "glVertexAttribI2iv", doThrow);
554             bindExtendedFunc(cast(void**)&glVertexAttribI2ui, "glVertexAttribI2ui", doThrow);
555             bindExtendedFunc(cast(void**)&glVertexAttribI2uiv, "glVertexAttribI2uiv", doThrow);
556             bindExtendedFunc(cast(void**)&glVertexAttribI3i, "glVertexAttribI3i", doThrow);
557             bindExtendedFunc(cast(void**)&glVertexAttribI3iv, "glVertexAttribI3iv", doThrow);
558             bindExtendedFunc(cast(void**)&glVertexAttribI3ui, "glVertexAttribI3ui", doThrow);
559             bindExtendedFunc(cast(void**)&glVertexAttribI3uiv, "glVertexAttribI3uiv", doThrow);
560             bindExtendedFunc(cast(void**)&glVertexAttribI4bv, "glVertexAttribI4bv", doThrow);
561             bindExtendedFunc(cast(void**)&glVertexAttribI4i, "glVertexAttribI4i", doThrow);
562             bindExtendedFunc(cast(void**)&glVertexAttribI4iv, "glVertexAttribI4iv", doThrow);
563             bindExtendedFunc(cast(void**)&glVertexAttribI4sv, "glVertexAttribI4sv", doThrow);
564             bindExtendedFunc(cast(void**)&glVertexAttribI4ubv, "glVertexAttribI4ubv", doThrow);
565             bindExtendedFunc(cast(void**)&glVertexAttribI4ui, "glVertexAttribI4ui", doThrow);
566             bindExtendedFunc(cast(void**)&glVertexAttribI4uiv, "glVertexAttribI4uiv", doThrow);
567             bindExtendedFunc(cast(void**)&glVertexAttribI4usv, "glVertexAttribI4usv", doThrow);
568             bindExtendedFunc(cast(void**)&glVertexAttribIPointer, "glVertexAttribIPointer", doThrow);
569             bindExtendedFunc(cast(void**)&glGetVertexAttribIiv, "glGetVertexAttribIiv", doThrow);
570             bindExtendedFunc(cast(void**)&glGetVertexAttribIuiv, "glGetVertexAttribIuiv", doThrow);
571             bindExtendedFunc(cast(void**)&glGetUniformuiv, "glGetUniformuiv", doThrow);
572             bindExtendedFunc(cast(void**)&glGetStringi, "glGetStringi", doThrow);
573 
574             _maxVersion = GLVersion.GL30;
575         }
576 
577         if(maxAvail >= GLVersion.GL31)
578         {
579             bindExtendedFunc(cast(void**)&glDrawArraysInstanced, "glDrawArraysInstanced", doThrow);
580             bindExtendedFunc(cast(void**)&glDrawElementsInstanced, "glDrawElementsInstanced", doThrow);
581             bindExtendedFunc(cast(void**)&glPrimitiveRestartIndex, "glPrimitiveRestartIndex", doThrow);
582             bindExtendedFunc(cast(void**)&glTexBuffer, "glTexBuffer", doThrow);
583 
584             _maxVersion = GLVersion.GL31;
585         }
586 
587         if(maxAvail >= GLVersion.GL32)
588         {
589             bindExtendedFunc(cast(void**)&glFramebufferTexture, "glFramebufferTexture", doThrow);
590             bindExtendedFunc(cast(void**)&glGetBufferParameteri64v, "glGetBufferParameteri64v", doThrow);
591             bindExtendedFunc(cast(void**)&glGetInteger64i_v, "glGetInteger64i_v", doThrow);
592 
593             _maxVersion = GLVersion.GL32;
594         }
595 
596         if(maxAvail >= GLVersion.GL33)
597         {
598             bindExtendedFunc(cast(void**)&glVertexAttribDivisor, "glVertexAttribDivisor", doThrow);
599 
600             _maxVersion = GLVersion.GL33;
601         }
602 
603         if(maxAvail >= GLVersion.GL40)
604         {
605             bindExtendedFunc(cast(void**)&glBlendEquationSeparatei, "glBlendEquationSeparatei", doThrow);
606             bindExtendedFunc(cast(void**)&glBlendEquationi, "glBlendEquationi", doThrow);
607             bindExtendedFunc(cast(void**)&glBlendFuncSeparatei, "glBlendFuncSeparatei", doThrow);
608             bindExtendedFunc(cast(void**)&glBlendFunci, "glBlendFunci", doThrow);
609             bindExtendedFunc(cast(void**)&glMinSampleShading, "glMinSampleShading", doThrow);
610 
611             _maxVersion = GLVersion.GL40;
612         }
613 
614         return _maxVersion;
615     }
616 
617     string versionToString(GLVersion ver)
618     {
619         switch(ver)
620         {
621             case GLVersion.GL40:
622                 return "OpenGL Version 4.0";
623             case GLVersion.GL33:
624                 return "OpenGL Version 3.3";
625             case GLVersion.GL32:
626                 return "OpenGL Version 3.2";
627             case GLVersion.GL31:
628                 return "OpenGL Version 3.1";
629             case GLVersion.GL30:
630                 return "OpenGL Version 3.0";
631             case GLVersion.GL21:
632                 return "OpenGL Version 2.1";
633             case GLVersion.GL20:
634                 return "OpenGL Version 2.0";
635             case GLVersion.GL15:
636                 return "OpenGL Version 1.5";
637             case GLVersion.GL14:
638                 return "OpenGL Version 1.4";
639             case GLVersion.GL13:
640                 return "OpenGL Version 1.3";
641             case GLVersion.GL12:
642                 return "OpenGL Version 1.2";
643             case GLVersion.GL11:
644                 return "OpenGL Version 1.1";
645             case GLVersion.None:
646                 return "OpenGL Version None";
647             default:
648                 break;
649         }
650         return "Uknown OpenGL Version";
651     }
652 
653     bool hasValidContext()
654     {
655         version(Windows)
656         {
657             if(wglGetCurrentContext() is null)
658                 return false;
659         }
660         else version(GLX)
661         {
662             if(glXGetCurrentContext() is null)
663                 return false;
664         }
665         else version(MacOSX)
666         {
667             if(CGLGetCurrentContext() is null)
668                 return false;
669         }
670         else
671         {
672             static assert(0, "DerelictGLLoader.hasValidContext is unimplemented for this platform");
673         }
674 
675         return true;
676     }
677 
678 protected:
679     override void loadSymbols()
680     {
681         // gl 1.0
682         bindFunc(cast(void**)&glClearIndex, "glClearIndex");
683         bindFunc(cast(void**)&glClearColor, "glClearColor");
684         bindFunc(cast(void**)&glClear, "glClear");
685         bindFunc(cast(void**)&glIndexMask, "glIndexMask");
686         bindFunc(cast(void**)&glColorMask, "glColorMask");
687         bindFunc(cast(void**)&glAlphaFunc, "glAlphaFunc");
688         bindFunc(cast(void**)&glBlendFunc, "glBlendFunc");
689         bindFunc(cast(void**)&glLogicOp, "glLogicOp");
690         bindFunc(cast(void**)&glCullFace, "glCullFace");
691         bindFunc(cast(void**)&glFrontFace, "glFrontFace");
692         bindFunc(cast(void**)&glPointSize, "glPointSize");
693         bindFunc(cast(void**)&glLineWidth, "glLineWidth");
694         bindFunc(cast(void**)&glLineStipple, "glLineStipple");
695         bindFunc(cast(void**)&glPolygonMode, "glPolygonMode");
696         bindFunc(cast(void**)&glPolygonOffset, "glPolygonOffset");
697         bindFunc(cast(void**)&glPolygonStipple, "glPolygonStipple");
698         bindFunc(cast(void**)&glGetPolygonStipple, "glGetPolygonStipple");
699         bindFunc(cast(void**)&glEdgeFlag, "glEdgeFlag");
700         bindFunc(cast(void**)&glEdgeFlagv, "glEdgeFlagv");
701         bindFunc(cast(void**)&glScissor, "glScissor");
702         bindFunc(cast(void**)&glClipPlane, "glClipPlane");
703         bindFunc(cast(void**)&glGetClipPlane, "glGetClipPlane");
704         bindFunc(cast(void**)&glDrawBuffer, "glDrawBuffer");
705         bindFunc(cast(void**)&glReadBuffer, "glReadBuffer");
706         bindFunc(cast(void**)&glEnable, "glEnable");
707         bindFunc(cast(void**)&glDisable, "glDisable");
708         bindFunc(cast(void**)&glIsEnabled, "glIsEnabled");
709         bindFunc(cast(void**)&glEnableClientState, "glEnableClientState");
710         bindFunc(cast(void**)&glDisableClientState, "glDisableClientState");
711         bindFunc(cast(void**)&glGetBooleanv, "glGetBooleanv");
712         bindFunc(cast(void**)&glGetDoublev, "glGetDoublev");
713         bindFunc(cast(void**)&glGetFloatv, "glGetFloatv");
714         bindFunc(cast(void**)&glGetIntegerv, "glGetIntegerv");
715         bindFunc(cast(void**)&glPushAttrib, "glPushAttrib");
716         bindFunc(cast(void**)&glPopAttrib, "glPopAttrib");
717         bindFunc(cast(void**)&glPushClientAttrib, "glPushClientAttrib");
718         bindFunc(cast(void**)&glPopClientAttrib, "glPopClientAttrib");
719         bindFunc(cast(void**)&glRenderMode, "glRenderMode");
720         bindFunc(cast(void**)&glGetError, "glGetError");
721         bindFunc(cast(void**)&glGetString, "glGetString");
722         bindFunc(cast(void**)&glFinish, "glFinish");
723         bindFunc(cast(void**)&glFlush, "glFlush");
724         bindFunc(cast(void**)&glHint, "glHint");
725         bindFunc(cast(void**)&glClearDepth, "glClearDepth");
726         bindFunc(cast(void**)&glDepthFunc, "glDepthFunc");
727         bindFunc(cast(void**)&glDepthMask, "glDepthMask");
728         bindFunc(cast(void**)&glDepthRange, "glDepthRange");
729         bindFunc(cast(void**)&glClearAccum, "glClearAccum");
730         bindFunc(cast(void**)&glAccum, "glAccum");
731         bindFunc(cast(void**)&glMatrixMode, "glMatrixMode");
732         bindFunc(cast(void**)&glOrtho, "glOrtho");
733         bindFunc(cast(void**)&glFrustum, "glFrustum");
734         bindFunc(cast(void**)&glViewport, "glViewport");
735         bindFunc(cast(void**)&glPushMatrix, "glPushMatrix");
736         bindFunc(cast(void**)&glPopMatrix, "glPopMatrix");
737         bindFunc(cast(void**)&glLoadIdentity, "glLoadIdentity");
738         bindFunc(cast(void**)&glLoadMatrixd, "glLoadMatrixd");
739         bindFunc(cast(void**)&glLoadMatrixf, "glLoadMatrixf");
740         bindFunc(cast(void**)&glMultMatrixd, "glMultMatrixd");
741         bindFunc(cast(void**)&glMultMatrixf, "glMultMatrixf");
742         bindFunc(cast(void**)&glRotated, "glRotated");
743         bindFunc(cast(void**)&glRotatef, "glRotatef");
744         bindFunc(cast(void**)&glScaled, "glScaled");
745         bindFunc(cast(void**)&glScalef, "glScalef");
746         bindFunc(cast(void**)&glTranslated, "glTranslated");
747         bindFunc(cast(void**)&glTranslatef, "glTranslatef");
748         bindFunc(cast(void**)&glIsList, "glIsList");
749         bindFunc(cast(void**)&glDeleteLists, "glDeleteLists");
750         bindFunc(cast(void**)&glGenLists, "glGenLists");
751         bindFunc(cast(void**)&glNewList, "glNewList");
752         bindFunc(cast(void**)&glEndList, "glEndList");
753         bindFunc(cast(void**)&glCallList, "glCallList");
754         bindFunc(cast(void**)&glCallLists, "glCallLists");
755         bindFunc(cast(void**)&glListBase, "glListBase");
756         bindFunc(cast(void**)&glBegin, "glBegin");
757         bindFunc(cast(void**)&glEnd, "glEnd");
758         bindFunc(cast(void**)&glVertex2d, "glVertex2d");
759         bindFunc(cast(void**)&glVertex2f, "glVertex2f");
760         bindFunc(cast(void**)&glVertex2i, "glVertex2i");
761         bindFunc(cast(void**)&glVertex2s, "glVertex2s");
762         bindFunc(cast(void**)&glVertex3d, "glVertex3d");
763         bindFunc(cast(void**)&glVertex3f, "glVertex3f");
764         bindFunc(cast(void**)&glVertex3i, "glVertex3i");
765         bindFunc(cast(void**)&glVertex3s, "glVertex3s");
766         bindFunc(cast(void**)&glVertex4d, "glVertex4d");
767         bindFunc(cast(void**)&glVertex4f, "glVertex4f");
768         bindFunc(cast(void**)&glVertex4i, "glVertex4i");
769         bindFunc(cast(void**)&glVertex4s, "glVertex4s");
770         bindFunc(cast(void**)&glVertex2dv, "glVertex2dv");
771         bindFunc(cast(void**)&glVertex2fv, "glVertex2fv");
772         bindFunc(cast(void**)&glVertex2iv, "glVertex2iv");
773         bindFunc(cast(void**)&glVertex2sv, "glVertex2sv");
774         bindFunc(cast(void**)&glVertex3dv, "glVertex3dv");
775         bindFunc(cast(void**)&glVertex3fv, "glVertex3fv");
776         bindFunc(cast(void**)&glVertex3iv, "glVertex3iv");
777         bindFunc(cast(void**)&glVertex3sv, "glVertex3sv");
778         bindFunc(cast(void**)&glVertex4dv, "glVertex4dv");
779         bindFunc(cast(void**)&glVertex4fv, "glVertex4fv");
780         bindFunc(cast(void**)&glVertex4iv, "glVertex4iv");
781         bindFunc(cast(void**)&glVertex4sv, "glVertex4sv");
782         bindFunc(cast(void**)&glNormal3b, "glNormal3b");
783         bindFunc(cast(void**)&glNormal3d, "glNormal3d");
784         bindFunc(cast(void**)&glNormal3f, "glNormal3f");
785         bindFunc(cast(void**)&glNormal3i, "glNormal3i");
786         bindFunc(cast(void**)&glNormal3s, "glNormal3s");
787         bindFunc(cast(void**)&glNormal3bv, "glNormal3bv");
788         bindFunc(cast(void**)&glNormal3dv, "glNormal3dv");
789         bindFunc(cast(void**)&glNormal3fv, "glNormal3fv");
790         bindFunc(cast(void**)&glNormal3iv, "glNormal3iv");
791         bindFunc(cast(void**)&glNormal3sv, "glNormal3sv");
792         bindFunc(cast(void**)&glIndexd, "glIndexd");
793         bindFunc(cast(void**)&glIndexf, "glIndexf");
794         bindFunc(cast(void**)&glIndexi, "glIndexi");
795         bindFunc(cast(void**)&glIndexs, "glIndexs");
796         bindFunc(cast(void**)&glIndexub, "glIndexub");
797         bindFunc(cast(void**)&glIndexdv, "glIndexdv");
798         bindFunc(cast(void**)&glIndexfv, "glIndexfv");
799         bindFunc(cast(void**)&glIndexiv, "glIndexiv");
800         bindFunc(cast(void**)&glIndexsv, "glIndexsv");
801         bindFunc(cast(void**)&glIndexubv, "glIndexubv");
802         bindFunc(cast(void**)&glColor3b, "glColor3b");
803         bindFunc(cast(void**)&glColor3d, "glColor3d");
804         bindFunc(cast(void**)&glColor3f, "glColor3f");
805         bindFunc(cast(void**)&glColor3i, "glColor3i");
806         bindFunc(cast(void**)&glColor3s, "glColor3s");
807         bindFunc(cast(void**)&glColor3ub, "glColor3ub");
808         bindFunc(cast(void**)&glColor3ui, "glColor3ui");
809         bindFunc(cast(void**)&glColor3us, "glColor3us");
810         bindFunc(cast(void**)&glColor4b, "glColor4b");
811         bindFunc(cast(void**)&glColor4d, "glColor4d");
812         bindFunc(cast(void**)&glColor4f, "glColor4f");
813         bindFunc(cast(void**)&glColor4i, "glColor4i");
814         bindFunc(cast(void**)&glColor4s, "glColor4s");
815         bindFunc(cast(void**)&glColor4ub, "glColor4ub");
816         bindFunc(cast(void**)&glColor4ui, "glColor4ui");
817         bindFunc(cast(void**)&glColor4us, "glColor4us");
818         bindFunc(cast(void**)&glColor3bv, "glColor3bv");
819         bindFunc(cast(void**)&glColor3dv, "glColor3dv");
820         bindFunc(cast(void**)&glColor3fv, "glColor3fv");
821         bindFunc(cast(void**)&glColor3iv, "glColor3iv");
822         bindFunc(cast(void**)&glColor3sv, "glColor3sv");
823         bindFunc(cast(void**)&glColor3ubv, "glColor3ubv");
824         bindFunc(cast(void**)&glColor3uiv, "glColor3uiv");
825         bindFunc(cast(void**)&glColor3usv, "glColor3usv");
826         bindFunc(cast(void**)&glColor4bv, "glColor4bv");
827         bindFunc(cast(void**)&glColor4dv, "glColor4dv");
828         bindFunc(cast(void**)&glColor4fv, "glColor4fv");
829         bindFunc(cast(void**)&glColor4iv, "glColor4iv");
830         bindFunc(cast(void**)&glColor4sv, "glColor4sv");
831         bindFunc(cast(void**)&glColor4ubv, "glColor4ubv");
832         bindFunc(cast(void**)&glColor4uiv, "glColor4uiv");
833         bindFunc(cast(void**)&glColor4usv, "glColor4usv");
834         bindFunc(cast(void**)&glTexCoord1d, "glTexCoord1d");
835         bindFunc(cast(void**)&glTexCoord1f, "glTexCoord1f");
836         bindFunc(cast(void**)&glTexCoord1i, "glTexCoord1i");
837         bindFunc(cast(void**)&glTexCoord1s, "glTexCoord1s");
838         bindFunc(cast(void**)&glTexCoord2d, "glTexCoord2d");
839         bindFunc(cast(void**)&glTexCoord2f, "glTexCoord2f");
840         bindFunc(cast(void**)&glTexCoord2i, "glTexCoord2i");
841         bindFunc(cast(void**)&glTexCoord2s, "glTexCoord2s");
842         bindFunc(cast(void**)&glTexCoord3d, "glTexCoord3d");
843         bindFunc(cast(void**)&glTexCoord3f, "glTexCoord3f");
844         bindFunc(cast(void**)&glTexCoord3i, "glTexCoord3i");
845         bindFunc(cast(void**)&glTexCoord3s, "glTexCoord3s");
846         bindFunc(cast(void**)&glTexCoord4d, "glTexCoord4d");
847         bindFunc(cast(void**)&glTexCoord4f, "glTexCoord4f");
848         bindFunc(cast(void**)&glTexCoord4i, "glTexCoord4i");
849         bindFunc(cast(void**)&glTexCoord4s, "glTexCoord4s");
850         bindFunc(cast(void**)&glTexCoord1dv, "glTexCoord1dv");
851         bindFunc(cast(void**)&glTexCoord1fv, "glTexCoord1fv");
852         bindFunc(cast(void**)&glTexCoord1iv, "glTexCoord1iv");
853         bindFunc(cast(void**)&glTexCoord1sv, "glTexCoord1sv");
854         bindFunc(cast(void**)&glTexCoord2dv, "glTexCoord2dv");
855         bindFunc(cast(void**)&glTexCoord2fv, "glTexCoord2fv");
856         bindFunc(cast(void**)&glTexCoord2iv, "glTexCoord2iv");
857         bindFunc(cast(void**)&glTexCoord2sv, "glTexCoord2sv");
858         bindFunc(cast(void**)&glTexCoord3dv, "glTexCoord3dv");
859         bindFunc(cast(void**)&glTexCoord3fv, "glTexCoord3fv");
860         bindFunc(cast(void**)&glTexCoord3iv, "glTexCoord3iv");
861         bindFunc(cast(void**)&glTexCoord3sv, "glTexCoord3sv");
862         bindFunc(cast(void**)&glTexCoord4dv, "glTexCoord4dv");
863         bindFunc(cast(void**)&glTexCoord4fv, "glTexCoord4fv");
864         bindFunc(cast(void**)&glTexCoord4iv, "glTexCoord4iv");
865         bindFunc(cast(void**)&glTexCoord4sv, "glTexCoord4sv");
866         bindFunc(cast(void**)&glRasterPos2d, "glRasterPos2d");
867         bindFunc(cast(void**)&glRasterPos2f, "glRasterPos2f");
868         bindFunc(cast(void**)&glRasterPos2i, "glRasterPos2i");
869         bindFunc(cast(void**)&glRasterPos2s, "glRasterPos2s");
870         bindFunc(cast(void**)&glRasterPos3d, "glRasterPos3d");
871         bindFunc(cast(void**)&glRasterPos3f, "glRasterPos3f");
872         bindFunc(cast(void**)&glRasterPos3i, "glRasterPos3i");
873         bindFunc(cast(void**)&glRasterPos3s, "glRasterPos3s");
874         bindFunc(cast(void**)&glRasterPos4d, "glRasterPos4d");
875         bindFunc(cast(void**)&glRasterPos4f, "glRasterPos4f");
876         bindFunc(cast(void**)&glRasterPos4i, "glRasterPos4i");
877         bindFunc(cast(void**)&glRasterPos4s, "glRasterPos4s");
878         bindFunc(cast(void**)&glRasterPos2dv, "glRasterPos2dv");
879         bindFunc(cast(void**)&glRasterPos2fv, "glRasterPos2fv");
880         bindFunc(cast(void**)&glRasterPos2iv, "glRasterPos2iv");
881         bindFunc(cast(void**)&glRasterPos2sv, "glRasterPos2sv");
882         bindFunc(cast(void**)&glRasterPos3dv, "glRasterPos3dv");
883         bindFunc(cast(void**)&glRasterPos3fv, "glRasterPos3fv");
884         bindFunc(cast(void**)&glRasterPos3iv, "glRasterPos3iv");
885         bindFunc(cast(void**)&glRasterPos3sv, "glRasterPos3sv");
886         bindFunc(cast(void**)&glRasterPos4dv, "glRasterPos4dv");
887         bindFunc(cast(void**)&glRasterPos4fv, "glRasterPos4fv");
888         bindFunc(cast(void**)&glRasterPos4iv, "glRasterPos4iv");
889         bindFunc(cast(void**)&glRasterPos4sv, "glRasterPos4sv");
890         bindFunc(cast(void**)&glRectd, "glRectd");
891         bindFunc(cast(void**)&glRectf, "glRectf");
892         bindFunc(cast(void**)&glRecti, "glRecti");
893         bindFunc(cast(void**)&glRects, "glRects");
894         bindFunc(cast(void**)&glRectdv, "glRectdv");
895         bindFunc(cast(void**)&glRectfv, "glRectfv");
896         bindFunc(cast(void**)&glRectiv, "glRectiv");
897         bindFunc(cast(void**)&glRectsv, "glRectsv");
898         bindFunc(cast(void**)&glShadeModel, "glShadeModel");
899         bindFunc(cast(void**)&glLightf, "glLightf");
900         bindFunc(cast(void**)&glLighti, "glLighti");
901         bindFunc(cast(void**)&glLightfv, "glLightfv");
902         bindFunc(cast(void**)&glLightiv, "glLightiv");
903         bindFunc(cast(void**)&glGetLightfv, "glGetLightfv");
904         bindFunc(cast(void**)&glGetLightiv, "glGetLightiv");
905         bindFunc(cast(void**)&glLightModelf, "glLightModelf");
906         bindFunc(cast(void**)&glLightModeli, "glLightModeli");
907         bindFunc(cast(void**)&glLightModelfv, "glLightModelfv");
908         bindFunc(cast(void**)&glLightModeliv, "glLightModeliv");
909         bindFunc(cast(void**)&glMaterialf, "glMaterialf");
910         bindFunc(cast(void**)&glMateriali, "glMateriali");
911         bindFunc(cast(void**)&glMaterialfv, "glMaterialfv");
912         bindFunc(cast(void**)&glMaterialiv, "glMaterialiv");
913         bindFunc(cast(void**)&glGetMaterialfv, "glGetMaterialfv");
914         bindFunc(cast(void**)&glGetMaterialiv, "glGetMaterialiv");
915         bindFunc(cast(void**)&glColorMaterial, "glColorMaterial");
916         bindFunc(cast(void**)&glPixelZoom, "glPixelZoom");
917         bindFunc(cast(void**)&glPixelStoref, "glPixelStoref");
918         bindFunc(cast(void**)&glPixelStorei, "glPixelStorei");
919         bindFunc(cast(void**)&glPixelTransferf, "glPixelTransferf");
920         bindFunc(cast(void**)&glPixelTransferi, "glPixelTransferi");
921         bindFunc(cast(void**)&glPixelMapfv, "glPixelMapfv");
922         bindFunc(cast(void**)&glPixelMapuiv, "glPixelMapuiv");
923         bindFunc(cast(void**)&glPixelMapusv, "glPixelMapusv");
924         bindFunc(cast(void**)&glGetPixelMapfv, "glGetPixelMapfv");
925         bindFunc(cast(void**)&glGetPixelMapuiv, "glGetPixelMapuiv");
926         bindFunc(cast(void**)&glGetPixelMapusv, "glGetPixelMapusv");
927         bindFunc(cast(void**)&glBitmap, "glBitmap");
928         bindFunc(cast(void**)&glReadPixels, "glReadPixels");
929         bindFunc(cast(void**)&glDrawPixels, "glDrawPixels");
930         bindFunc(cast(void**)&glCopyPixels, "glCopyPixels");
931         bindFunc(cast(void**)&glStencilFunc, "glStencilFunc");
932         bindFunc(cast(void**)&glStencilMask, "glStencilMask");
933         bindFunc(cast(void**)&glStencilOp, "glStencilOp");
934         bindFunc(cast(void**)&glClearStencil, "glClearStencil");
935         bindFunc(cast(void**)&glTexGend, "glTexGend");
936         bindFunc(cast(void**)&glTexGenf, "glTexGenf");
937         bindFunc(cast(void**)&glTexGeni, "glTexGeni");
938         bindFunc(cast(void**)&glTexGendv, "glTexGendv");
939         bindFunc(cast(void**)&glTexGenfv, "glTexGenfv");
940         bindFunc(cast(void**)&glTexGeniv, "glTexGeniv");
941         bindFunc(cast(void**)&glTexEnvf, "glTexEnvf");
942         bindFunc(cast(void**)&glTexEnvi, "glTexEnvi");
943         bindFunc(cast(void**)&glTexEnvfv, "glTexEnvfv");
944         bindFunc(cast(void**)&glTexEnviv, "glTexEnviv");
945         bindFunc(cast(void**)&glGetTexEnvfv, "glGetTexEnvfv");
946         bindFunc(cast(void**)&glGetTexEnviv, "glGetTexEnviv");
947         bindFunc(cast(void**)&glTexParameterf, "glTexParameterf");
948         bindFunc(cast(void**)&glTexParameteri, "glTexParameteri");
949         bindFunc(cast(void**)&glTexParameterfv, "glTexParameterfv");
950         bindFunc(cast(void**)&glTexParameteriv, "glTexParameteriv");
951         bindFunc(cast(void**)&glGetTexParameterfv, "glGetTexParameterfv");
952         bindFunc(cast(void**)&glGetTexParameteriv, "glGetTexParameteriv");
953         bindFunc(cast(void**)&glGetTexLevelParameterfv, "glGetTexLevelParameterfv");
954         bindFunc(cast(void**)&glGetTexLevelParameteriv, "glGetTexLevelParameteriv");
955         bindFunc(cast(void**)&glTexImage1D, "glTexImage1D");
956         bindFunc(cast(void**)&glTexImage2D, "glTexImage2D");
957         bindFunc(cast(void**)&glGetTexImage, "glGetTexImage");
958         bindFunc(cast(void**)&glMap1d, "glMap1d");
959         bindFunc(cast(void**)&glMap1f, "glMap1f");
960         bindFunc(cast(void**)&glMap2d, "glMap2d");
961         bindFunc(cast(void**)&glMap2f, "glMap2f");
962         bindFunc(cast(void**)&glGetMapdv, "glGetMapdv");
963         bindFunc(cast(void**)&glGetMapfv, "glGetMapfv");
964         bindFunc(cast(void**)&glEvalCoord1d, "glEvalCoord1d");
965         bindFunc(cast(void**)&glEvalCoord1f, "glEvalCoord1f");
966         bindFunc(cast(void**)&glEvalCoord1dv, "glEvalCoord1dv");
967         bindFunc(cast(void**)&glEvalCoord1fv, "glEvalCoord1fv");
968         bindFunc(cast(void**)&glEvalCoord2d, "glEvalCoord2d");
969         bindFunc(cast(void**)&glEvalCoord2f, "glEvalCoord2f");
970         bindFunc(cast(void**)&glEvalCoord2dv, "glEvalCoord2dv");
971         bindFunc(cast(void**)&glEvalCoord2fv, "glEvalCoord2fv");
972         bindFunc(cast(void**)&glMapGrid1d, "glMapGrid1d");
973         bindFunc(cast(void**)&glMapGrid1f, "glMapGrid1f");
974         bindFunc(cast(void**)&glMapGrid2d, "glMapGrid2d");
975         bindFunc(cast(void**)&glMapGrid2f, "glMapGrid2f");
976         bindFunc(cast(void**)&glEvalPoint1, "glEvalPoint1");
977         bindFunc(cast(void**)&glEvalPoint2, "glEvalPoint2");
978         bindFunc(cast(void**)&glEvalMesh1, "glEvalMesh1");
979         bindFunc(cast(void**)&glEvalMesh2, "glEvalMesh2");
980         bindFunc(cast(void**)&glFogf, "glFogf");
981         bindFunc(cast(void**)&glFogi, "glFogi");
982         bindFunc(cast(void**)&glFogfv, "glFogfv");
983         bindFunc(cast(void**)&glFogiv, "glFogiv");
984         bindFunc(cast(void**)&glFeedbackBuffer, "glFeedbackBuffer");
985         bindFunc(cast(void**)&glPassThrough, "glPassThrough");
986         bindFunc(cast(void**)&glSelectBuffer, "glSelectBuffer");
987         bindFunc(cast(void**)&glInitNames, "glInitNames");
988         bindFunc(cast(void**)&glLoadName, "glLoadName");
989         bindFunc(cast(void**)&glPushName, "glPushName");
990         bindFunc(cast(void**)&glPopName, "glPopName");
991         // gl 1.1
992         bindFunc(cast(void**)&glGenTextures, "glGenTextures");
993         bindFunc(cast(void**)&glDeleteTextures, "glDeleteTextures");
994         bindFunc(cast(void**)&glBindTexture, "glBindTexture");
995         bindFunc(cast(void**)&glPrioritizeTextures, "glPrioritizeTextures");
996         bindFunc(cast(void**)&glAreTexturesResident, "glAreTexturesResident");
997         bindFunc(cast(void**)&glIsTexture, "glIsTexture");
998         bindFunc(cast(void**)&glTexSubImage1D, "glTexSubImage1D");
999         bindFunc(cast(void**)&glTexSubImage2D, "glTexSubImage2D");
1000         bindFunc(cast(void**)&glCopyTexImage1D, "glCopyTexImage1D");
1001         bindFunc(cast(void**)&glCopyTexImage2D, "glCopyTexImage2D");
1002         bindFunc(cast(void**)&glCopyTexSubImage1D, "glCopyTexSubImage1D");
1003         bindFunc(cast(void**)&glCopyTexSubImage2D, "glCopyTexSubImage2D");
1004         bindFunc(cast(void**)&glVertexPointer, "glVertexPointer");
1005         bindFunc(cast(void**)&glNormalPointer, "glNormalPointer");
1006         bindFunc(cast(void**)&glColorPointer, "glColorPointer");
1007         bindFunc(cast(void**)&glIndexPointer, "glIndexPointer");
1008         bindFunc(cast(void**)&glTexCoordPointer, "glTexCoordPointer");
1009         bindFunc(cast(void**)&glEdgeFlagPointer, "glEdgeFlagPointer");
1010         bindFunc(cast(void**)&glGetPointerv, "glGetPointerv");
1011         bindFunc(cast(void**)&glArrayElement, "glArrayElement");
1012         bindFunc(cast(void**)&glDrawArrays, "glDrawArrays");
1013         bindFunc(cast(void**)&glDrawElements, "glDrawElements");
1014         bindFunc(cast(void**)&glInterleavedArrays, "glInterleavedArrays");
1015 
1016         loadPlatformGL(&bindFunc);
1017 
1018         _maxVersion = GLVersion.GL11;
1019     }
1020 
1021     public void bindExtendedFunc(void** ptr, string funcName, bool doThrow)
1022     {
1023         version(MacOSX)
1024         {
1025             bindFunc(ptr, funcName, doThrow);
1026         }
1027         else
1028         {
1029             void* func = loadGLSymbol(funcName);
1030             if(func is null && doThrow)
1031                 Derelict_HandleMissingSymbol(lib().name(), funcName);
1032             else
1033                 *ptr = func;
1034         }
1035     }
1036 }
1037 
1038 DerelictGLLoader DerelictGL;
1039 
1040 static this()
1041 {
1042     DerelictGL = new DerelictGLLoader();
1043 }
1044 
1045 static ~this()
1046 {
1047     if(SharedLibLoader.isAutoUnloadEnabled())
1048         DerelictGL.unload();
1049 }