1 
2 //          Copyright 2018 - 2021 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.opengl.bind.arb.core_43;
8 
9 import bindbc.loader;
10 import bindbc.opengl.config,
11        bindbc.opengl.context;
12 import bindbc.opengl.bind.types;
13 
14 static if(glSupport >= GLSupport.gl43) {
15     enum has43 = true;
16 }
17 else enum has43 = false;
18 
19 // ARB_clear_buffer_object
20 version(GL_ARB) enum useARBClearBufferObject = true;
21 else version(GL_ARB_clear_buffer_object) enum useARBClearBufferObject = true;
22 else enum useARBClearBufferObject = has43;
23 
24 static if(useARBClearBufferObject) {
25     private bool _hasARBClearBufferObject;
26     @nogc nothrow bool hasARBClearBufferObject() { return _hasARBClearBufferObject; }
27 
28     extern(System) @nogc nothrow {
29         alias pglClearBufferData = void function(GLenum,GLenum,GLenum,GLenum,const(void)*);
30         alias pglClearBufferSubData = void function(GLenum,GLenum,GLintptr,GLsizeiptr,GLenum,GLenum,const(void)*);
31         alias pglClearNamedBufferDataEXT = void function(GLuint,GLenum,GLenum,GLenum,const(void)*);
32         alias pglClearNamedBufferSubDataEXT = void function(GLuint,GLenum,GLenum,GLenum,GLsizeiptr,GLsizeiptr,const(void)*);
33     }
34 
35     __gshared {
36         pglClearBufferData glClearBufferData;
37         pglClearBufferSubData glClearBufferSubData;
38         pglClearNamedBufferDataEXT glClearNamedBufferDataEXT;
39         pglClearNamedBufferSubDataEXT glClearNamedBufferSubDataEXT;
40     }
41 
42     private @nogc nothrow
43     bool loadARBClearBufferObject(SharedLib lib, GLSupport contextVersion)
44     {
45         lib.bindGLSymbol(cast(void**)&glClearBufferData, "glClearBufferData");
46         lib.bindGLSymbol(cast(void**)&glClearBufferSubData, "glClearBufferSubData");
47 
48         // The previous two functions are required when loading GL 4.3,
49         // the next two are not. Save the result of resetErrorCountGL and
50         // use that for the return value.
51         bool ret = resetErrorCountGL();
52         if(hasExtension(contextVersion, "GL_EXT_direct_state_access ")) {
53             lib.bindGLSymbol(cast(void**)&glClearNamedBufferDataEXT, "glClearNamedBufferDataEXT");
54             lib.bindGLSymbol(cast(void**)&glClearNamedBufferSubDataEXT, "glClearNamedBufferSubDataEXT");
55 
56             // Ignore errors.
57             resetErrorCountGL();
58         }
59         return ret;
60     }
61 }
62 else enum hasARBClearBufferObject = false;
63 
64 // ARB_compute_shader
65 version(GL_ARB) enum useARBComputeShader = true;
66 else version(GL_ARB_compute_shader) enum useARBComputeShader = true;
67 else enum useARBComputeShader = has43;
68 
69 static if(useARBComputeShader) {
70     private bool _hasARBComputeShader;
71     @nogc nothrow bool hasARBComputeShader() { return _hasARBComputeShader; }
72 
73     enum : uint {
74         GL_COMPUTE_SHADER                 = 0x91B9,
75         GL_MAX_COMPUTE_UNIFORM_BLOCKS     = 0x91BB,
76         GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS = 0x91BC,
77         GL_MAX_COMPUTE_IMAGE_UNIFORMS     = 0x91BD,
78         GL_MAX_COMPUTE_SHARED_MEMORY_SIZE = 0x8262,
79         GL_MAX_COMPUTE_UNIFORM_COMPONENTS = 0x8263,
80         GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS = 0x8264,
81         GL_MAX_COMPUTE_ATOMIC_COUNTERS    = 0x8265,
82         GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS = 0x8266,
83         GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS  = 0x90EB,
84         GL_MAX_COMPUTE_WORK_GROUP_COUNT   = 0x91BE,
85         GL_MAX_COMPUTE_WORK_GROUP_SIZE    = 0x91BF,
86         GL_COMPUTE_WORK_GROUP_SIZE        = 0x8267,
87         GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER = 0x90EC,
88         GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER = 0x90ED,
89         GL_DISPATCH_INDIRECT_BUFFER       = 0x90EE,
90         GL_DISPATCH_INDIRECT_BUFFER_BINDING = 0x90EF,
91         GL_COMPUTE_SHADER_BIT             = 0x00000020,
92     }
93 
94     extern(System) @nogc nothrow {
95         alias pglDispatchCompute = void function(GLuint,GLuint,GLuint);
96         alias pglDispatchComputeIndirect = void function(GLintptr);
97     }
98 
99     __gshared {
100         pglDispatchCompute glDispatchCompute;
101         pglDispatchComputeIndirect glDispatchComputeIndirect;
102     }
103 
104     private @nogc nothrow
105     bool loadARBComputeShader(SharedLib lib, GLSupport contextVersion)
106     {
107         lib.bindGLSymbol(cast(void**)&glDispatchCompute, "glDispatchCompute");
108         lib.bindGLSymbol(cast(void**)&glDispatchComputeIndirect, "glDispatchComputeIndirect");
109         return resetErrorCountGL();
110     }
111 }
112 else enum hasARBComputeShader = false;
113 
114 // ARB_copy_image
115 version(GL_ARB) enum useARBCopyImage = true;
116 else version(GL_ARB_copy_image) enum useARBCopyImage = true;
117 else enum useARBCopyImage = 4;
118 
119 static if(useARBCopyImage) {
120     private bool _hasARBCopyImage;
121     @nogc nothrow bool hasARBCopyImage() { return _hasARBCopyImage; }
122 
123     extern(System) @nogc nothrow alias pglCopyImageSubData = void function(GLuint,GLenum,GLint,GLint,GLint,GLint,GLuint,GLenum,GLint,GLint,GLint,GLint,GLsizei,GLsizei,GLsizei);
124     __gshared pglCopyImageSubData glCopyImageSubData;
125 
126     private @nogc nothrow
127     bool loadARBCopyImage(SharedLib lib, GLSupport contextVersion)
128     {
129         lib.bindGLSymbol(cast(void**)&glCopyImageSubData, "glCopyImageSubData");
130         return resetErrorCountGL();
131     }
132 }
133 else enum hasARBCopyImage = false;
134 
135 // ARB_ES3_compatibility
136 version(GL_ARB) enum useARBES3Compatibility = true;
137 else version(GL_ARB_ES3_compatibility) enum useARBES3Compatibility = true;
138 else enum useARBES3Compatibility = 4;
139 
140 static if(useARBES3Compatibility) {
141     private bool _hasARBES3Compatibility;
142     @nogc nothrow bool hasARBES3Compatibility() { return _hasARBES3Compatibility; }
143 
144     enum : uint {
145         GL_COMPRESSED_RGB8_ETC2           = 0x9274,
146         GL_COMPRESSED_SRGB8_ETC2          = 0x9275,
147         GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
148         GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
149         GL_COMPRESSED_RGBA8_ETC2_EAC      = 0x9278,
150         GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
151         GL_COMPRESSED_R11_EAC             = 0x9270,
152         GL_COMPRESSED_SIGNED_R11_EAC      = 0x9271,
153         GL_COMPRESSED_RG11_EAC            = 0x9272,
154         GL_COMPRESSED_SIGNED_RG11_EAC     = 0x9273,
155         GL_PRIMITIVE_RESTART_FIXED_INDEX  = 0x8D69,
156         GL_ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A,
157         GL_MAX_ELEMENT_INDEX              = 0x8D6B,
158     }
159 }
160 else enum hasARBES3Compatibility = false;
161 
162 // ARB_explicit_uniform_location
163 version(GL_ARB) enum useARBExplicitUniformLocation = true;
164 else version(GL_ARB_explicit_uniform_location) enum useARBExplicitUniformLocation = true;
165 else enum useARBExplicitUniformLocation = 4;
166 
167 static if(useARBExplicitUniformLocation) {
168     private bool _hasARBExplicitUniformLocation;
169     @nogc nothrow bool hasARBExplicitUniformLocation() { return _hasARBExplicitUniformLocation; }
170 
171     enum uint GL_MAX_UNIFORM_LOCATIONS = 0x826E;
172 }
173 else enum hasARBExplicitUniformLocation = false;
174 
175 // ARB_framebuffer_no_attachments
176 version(GL_ARB) enum useARBFramebufferNoAttachments = true;
177 else version(GL_ARB_framebuffer_no_attachments) enum useARBFramebufferNoAttachments = true;
178 else enum useARBFramebufferNoAttachments = 4;
179 
180 static if(useARBFramebufferNoAttachments) {
181     private bool _hasARBFramebufferNoAttachments;
182     @nogc nothrow bool hasARBFramebufferNoAttachments() { return _hasARBFramebufferNoAttachments; }
183 
184     enum : uint {
185         GL_FRAMEBUFFER_DEFAULT_WIDTH      = 0x9310,
186         GL_FRAMEBUFFER_DEFAULT_HEIGHT     = 0x9311,
187         GL_FRAMEBUFFER_DEFAULT_LAYERS     = 0x9312,
188         GL_FRAMEBUFFER_DEFAULT_SAMPLES    = 0x9313,
189         GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS = 0x9314,
190         GL_MAX_FRAMEBUFFER_WIDTH          = 0x9315,
191         GL_MAX_FRAMEBUFFER_HEIGHT         = 0x9316,
192         GL_MAX_FRAMEBUFFER_LAYERS         = 0x9317,
193         GL_MAX_FRAMEBUFFER_SAMPLES        = 0x9318,
194     }
195 
196     extern(System) @nogc nothrow {
197         alias pglFramebufferParameteri = void function(GLenum,GLenum,GLint);
198         alias pglGetFramebufferParameteriv = void function(GLenum,GLenum,GLint*);
199         alias pglNamedFramebufferParameteriEXT = void function(GLuint,GLenum,GLint);
200         alias pglGetNamedFramebufferParameterivEXT = void function(GLuint,GLenum,GLint*);
201     }
202 
203     __gshared {
204         pglFramebufferParameteri glFramebufferParameteri;
205         pglGetFramebufferParameteriv glGetFramebufferParameteriv;
206         pglNamedFramebufferParameteriEXT glNamedFramebufferParameteriEXT;
207         pglGetNamedFramebufferParameterivEXT glGetNamedFramebufferParameterivEXT;
208     }
209 
210     private @nogc nothrow
211     bool loadARBFramebufferNoAttachments(SharedLib lib, GLSupport contextVersion)
212     {
213         lib.bindGLSymbol(cast(void**)&glFramebufferParameteri, "glFramebufferParameteri");
214         lib.bindGLSymbol(cast(void**)&glGetFramebufferParameteriv, "glGetFramebufferParameteriv");
215 
216         // The previous two functions are required when loading GL 4.3,
217         // the next two are not. Save the result of resetErrorCountGL and
218         // use that for the return value.
219         bool ret = resetErrorCountGL();
220         if(hasExtension(contextVersion, "GL_EXT_direct_state_access ")) {
221             lib.bindGLSymbol(cast(void**)&glNamedFramebufferParameteriEXT, "glNamedFramebufferParameteriEXT");
222             lib.bindGLSymbol(cast(void**)&glGetNamedFramebufferParameterivEXT, "glGetNamedFramebufferParameterivEXT");
223 
224             // Ignore errors.
225             resetErrorCountGL();
226         }
227         return ret;
228     }
229 }
230 else enum hasARBFramebufferNoAttachments = false;
231 
232 // ARB_internalformat_query2
233 version(GL_ARB) enum useARBInternalFormatQuery2 = true;
234 else version(GL_ARB_internalformat_query2) enum useARBInternalFormatQuery2 = true;
235 else enum useARBInternalFormatQuery2 = has43;
236 
237 static if(useARBInternalFormatQuery2) {
238     private bool _hasARBInternalFormatQuery2;
239     @nogc nothrow bool hasARBInternalFormatQuery2() { return _hasARBInternalFormatQuery2; }
240 
241     enum : uint {
242         GL_INTERNALFORMAT_SUPPORTED       = 0x826F,
243         GL_INTERNALFORMAT_PREFERRED       = 0x8270,
244         GL_INTERNALFORMAT_RED_SIZE        = 0x8271,
245         GL_INTERNALFORMAT_GREEN_SIZE      = 0x8272,
246         GL_INTERNALFORMAT_BLUE_SIZE       = 0x8273,
247         GL_INTERNALFORMAT_ALPHA_SIZE      = 0x8274,
248         GL_INTERNALFORMAT_DEPTH_SIZE      = 0x8275,
249         GL_INTERNALFORMAT_STENCIL_SIZE    = 0x8276,
250         GL_INTERNALFORMAT_SHARED_SIZE     = 0x8277,
251         GL_INTERNALFORMAT_RED_TYPE        = 0x8278,
252         GL_INTERNALFORMAT_GREEN_TYPE      = 0x8279,
253         GL_INTERNALFORMAT_BLUE_TYPE       = 0x827A,
254         GL_INTERNALFORMAT_ALPHA_TYPE      = 0x827B,
255         GL_INTERNALFORMAT_DEPTH_TYPE      = 0x827C,
256         GL_INTERNALFORMAT_STENCIL_TYPE    = 0x827D,
257         GL_MAX_WIDTH                      = 0x827E,
258         GL_MAX_HEIGHT                     = 0x827F,
259         GL_MAX_DEPTH                      = 0x8280,
260         GL_MAX_LAYERS                     = 0x8281,
261         GL_MAX_COMBINED_DIMENSIONS        = 0x8282,
262         GL_COLOR_COMPONENTS               = 0x8283,
263         GL_DEPTH_COMPONENTS               = 0x8284,
264         GL_STENCIL_COMPONENTS             = 0x8285,
265         GL_COLOR_RENDERABLE               = 0x8286,
266         GL_DEPTH_RENDERABLE               = 0x8287,
267         GL_STENCIL_RENDERABLE             = 0x8288,
268         GL_FRAMEBUFFER_RENDERABLE         = 0x8289,
269         GL_FRAMEBUFFER_RENDERABLE_LAYERED = 0x828A,
270         GL_FRAMEBUFFER_BLEND              = 0x828B,
271         GL_READ_PIXELS                    = 0x828C,
272         GL_READ_PIXELS_FORMAT             = 0x828D,
273         GL_READ_PIXELS_TYPE               = 0x828E,
274         GL_TEXTURE_IMAGE_FORMAT           = 0x828F,
275         GL_TEXTURE_IMAGE_TYPE             = 0x8290,
276         GL_GET_TEXTURE_IMAGE_FORMAT       = 0x8291,
277         GL_GET_TEXTURE_IMAGE_TYPE         = 0x8292,
278         GL_MIPMAP                         = 0x8293,
279         GL_MANUAL_GENERATE_MIPMAP         = 0x8294,
280         GL_AUTO_GENERATE_MIPMAP           = 0x8295,
281         GL_COLOR_ENCODING                 = 0x8296,
282         GL_SRGB_READ                      = 0x8297,
283         GL_SRGB_WRITE                     = 0x8298,
284         GL_SRGB_DECODE_ARB                = 0x8299,
285         GL_FILTER                         = 0x829A,
286         GL_VERTEX_TEXTURE                 = 0x829B,
287         GL_TESS_CONTROL_TEXTURE           = 0x829C,
288         GL_TESS_EVALUATION_TEXTURE        = 0x829D,
289         GL_GEOMETRY_TEXTURE               = 0x829E,
290         GL_FRAGMENT_TEXTURE               = 0x829F,
291         GL_COMPUTE_TEXTURE                = 0x82A0,
292         GL_TEXTURE_SHADOW                 = 0x82A1,
293         GL_TEXTURE_GATHER                 = 0x82A2,
294         GL_TEXTURE_GATHER_SHADOW          = 0x82A3,
295         GL_SHADER_IMAGE_LOAD              = 0x82A4,
296         GL_SHADER_IMAGE_STORE             = 0x82A5,
297         GL_SHADER_IMAGE_ATOMIC            = 0x82A6,
298         GL_IMAGE_TEXEL_SIZE               = 0x82A7,
299         GL_IMAGE_COMPATIBILITY_CLASS      = 0x82A8,
300         GL_IMAGE_PIXEL_FORMAT             = 0x82A9,
301         GL_IMAGE_PIXEL_TYPE               = 0x82AA,
302         GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST = 0x82AC,
303         GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST = 0x82AD,
304         GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE = 0x82AE,
305         GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE = 0x82AF,
306         GL_TEXTURE_COMPRESSED_BLOCK_WIDTH = 0x82B1,
307         GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT = 0x82B2,
308         GL_TEXTURE_COMPRESSED_BLOCK_SIZE  = 0x82B3,
309         GL_CLEAR_BUFFER                   = 0x82B4,
310         GL_TEXTURE_VIEW                   = 0x82B5,
311         GL_VIEW_COMPATIBILITY_CLASS       = 0x82B6,
312         GL_FULL_SUPPORT                   = 0x82B7,
313         GL_CAVEAT_SUPPORT                 = 0x82B8,
314         GL_IMAGE_CLASS_4_X_32             = 0x82B9,
315         GL_IMAGE_CLASS_2_X_32             = 0x82BA,
316         GL_IMAGE_CLASS_1_X_32             = 0x82BB,
317         GL_IMAGE_CLASS_4_X_16             = 0x82BC,
318         GL_IMAGE_CLASS_2_X_16             = 0x82BD,
319         GL_IMAGE_CLASS_1_X_16             = 0x82BE,
320         GL_IMAGE_CLASS_4_X_8              = 0x82BF,
321         GL_IMAGE_CLASS_2_X_8              = 0x82C0,
322         GL_IMAGE_CLASS_1_X_8              = 0x82C1,
323         GL_IMAGE_CLASS_11_11_10           = 0x82C2,
324         GL_IMAGE_CLASS_10_10_10_2         = 0x82C3,
325         GL_VIEW_CLASS_128_BITS            = 0x82C4,
326         GL_VIEW_CLASS_96_BITS             = 0x82C5,
327         GL_VIEW_CLASS_64_BITS             = 0x82C6,
328         GL_VIEW_CLASS_48_BITS             = 0x82C7,
329         GL_VIEW_CLASS_32_BITS             = 0x82C8,
330         GL_VIEW_CLASS_24_BITS             = 0x82C9,
331         GL_VIEW_CLASS_16_BITS             = 0x82CA,
332         GL_VIEW_CLASS_8_BITS              = 0x82CB,
333         GL_VIEW_CLASS_S3TC_DXT1_RGB       = 0x82CC,
334         GL_VIEW_CLASS_S3TC_DXT1_RGBA      = 0x82CD,
335         GL_VIEW_CLASS_S3TC_DXT3_RGBA      = 0x82CE,
336         GL_VIEW_CLASS_S3TC_DXT5_RGBA      = 0x82CF,
337         GL_VIEW_CLASS_RGTC1_RED           = 0x82D0,
338         GL_VIEW_CLASS_RGTC2_RG            = 0x82D1,
339         GL_VIEW_CLASS_BPTC_UNORM          = 0x82D2,
340         GL_VIEW_CLASS_BPTC_FLOAT          = 0x82D3,
341     }
342 
343     extern(System) @nogc nothrow alias pglGetInternalformati64v = void function(GLenum,GLenum,GLenum,GLsizei,GLint64*);
344     __gshared pglGetInternalformati64v glGetInternalformati64v;
345 
346     private @nogc nothrow
347     bool loadARBInternalFormatQuery2(SharedLib lib, GLSupport contextVersion)
348     {
349         lib.bindGLSymbol(cast(void**)&glGetInternalformati64v, "glGetInternalformati64v");
350         return resetErrorCountGL();
351     }
352 }
353 else enum hasARBInternalFormatQuery2 = false;
354 
355 // ARB_invalidate_subdata
356 version(GL_ARB) enum useARBInvalidateSubdata = true;
357 else version(GL_ARB_invalidate_subdata) enum useARBInvalidateSubdata = true;
358 else enum useARBInvalidateSubdata = has43;
359 
360 static if(useARBInvalidateSubdata) {
361     private bool _hasARBInvalidateSubdata;
362     @nogc nothrow bool hasARBInvalidateSubdata() { return _hasARBInvalidateSubdata; }
363 
364     extern(System) @nogc nothrow {
365         alias pglInvalidateTexSubImage = void function(GLuint,GLint,GLint,GLint,GLint,GLsizei,GLsizei,GLsizei);
366         alias pglInvalidateTexImage = void function(GLuint,GLint);
367         alias pglInvalidateBufferSubData = void function(GLuint,GLintptr,GLsizeiptr);
368         alias pglInvalidateBufferData = void function(GLuint);
369         alias pglInvalidateFramebuffer = void function(GLenum,GLsizei,const(GLenum)*);
370         alias pglInvalidateSubFramebuffer = void function(GLenum,GLsizei,const(GLenum)*,GLint,GLint,GLsizei,GLsizei);
371     }
372 
373     __gshared {
374         pglInvalidateTexSubImage glInvalidateTexSubImage;
375         pglInvalidateTexImage glInvalidateTexImage;
376         pglInvalidateBufferSubData glInvalidateBufferSubData;
377         pglInvalidateBufferData glInvalidateBufferData;
378         pglInvalidateFramebuffer glInvalidateFramebuffer;
379         pglInvalidateSubFramebuffer glInvalidateSubFramebuffer;
380     }
381 
382     private @nogc nothrow
383     bool loadARBInvalidateSubdata(SharedLib lib, GLSupport contextVersion)
384     {
385         lib.bindGLSymbol(cast(void**)&glInvalidateTexSubImage, "glInvalidateTexSubImage");
386         lib.bindGLSymbol(cast(void**)&glInvalidateTexImage, "glInvalidateTexImage");
387         lib.bindGLSymbol(cast(void**)&glInvalidateBufferSubData, "glInvalidateBufferSubData");
388         lib.bindGLSymbol(cast(void**)&glInvalidateBufferData, "glInvalidateBufferData");
389         lib.bindGLSymbol(cast(void**)&glInvalidateFramebuffer, "glInvalidateFramebuffer");
390         lib.bindGLSymbol(cast(void**)&glInvalidateSubFramebuffer, "glInvalidateSubFramebuffer");
391         return resetErrorCountGL();
392     }
393 }
394 else enum hasARBInvalidateSubdata = false;
395 
396 // ARB_multi_draw_indirect
397 version(GL_ARB) enum useARBMultiDrawIndirect = true;
398 else version(GL_ARB_multi_draw_indirect) enum useARBMultiDrawIndirect = true;
399 else enum useARBMultiDrawIndirect = has43;
400 
401 static if(useARBMultiDrawIndirect) {
402     private bool _hasARBMultiDrawIndirect;
403     @nogc nothrow bool hasARBMultiDrawIndirect() { return _hasARBMultiDrawIndirect; }
404 
405     extern(System) @nogc nothrow {
406         alias pglMultiDrawArraysIndirect = void function(GLenum,const(void)*,GLsizei,GLsizei);
407         alias pglMultiDrawElementsIndirect = void function(GLenum,GLenum,const(void)*,GLsizei,GLsizei);
408     }
409 
410     __gshared {
411         pglMultiDrawArraysIndirect glMultiDrawArraysIndirect;
412         pglMultiDrawElementsIndirect glMultiDrawElementsIndirect;
413     }
414 
415     private @nogc nothrow
416     bool loadARBMultiDrawIndirect(SharedLib lib, GLSupport contextVersion)
417     {
418         lib.bindGLSymbol(cast(void**)&glMultiDrawArraysIndirect, "glMultiDrawArraysIndirect");
419         lib.bindGLSymbol(cast(void**)&glMultiDrawElementsIndirect, "glMultiDrawElementsIndirect");
420         return resetErrorCountGL();
421     }
422 }
423 else enum hasARBMultiDrawIndirect = false;
424 
425 // ARB_program_interface_query
426 version(GL_ARB) enum useARBProgramInterfaceQuery = true;
427 else version(GL_ARB_program_interface_query) enum useARBProgramInterfaceQuery = true;
428 else enum useARBProgramInterfaceQuery = has43;
429 
430 static if(useARBProgramInterfaceQuery) {
431     private bool _hasARBProgramInterfaceQuery;
432     @nogc nothrow bool hasARBProgramInterfaceQuery() { return _hasARBProgramInterfaceQuery; }
433 
434     enum : uint {
435         GL_UNIFORM                        = 0x92E1,
436         GL_UNIFORM_BLOCK                  = 0x92E2,
437         GL_PROGRAM_INPUT                  = 0x92E3,
438         GL_PROGRAM_OUTPUT                 = 0x92E4,
439         GL_BUFFER_VARIABLE                = 0x92E5,
440         GL_SHADER_STORAGE_BLOCK           = 0x92E6,
441         GL_VERTEX_SUBROUTINE              = 0x92E8,
442         GL_TESS_CONTROL_SUBROUTINE        = 0x92E9,
443         GL_TESS_EVALUATION_SUBROUTINE     = 0x92EA,
444         GL_GEOMETRY_SUBROUTINE            = 0x92EB,
445         GL_FRAGMENT_SUBROUTINE            = 0x92EC,
446         GL_COMPUTE_SUBROUTINE             = 0x92ED,
447         GL_VERTEX_SUBROUTINE_UNIFORM      = 0x92EE,
448         GL_TESS_CONTROL_SUBROUTINE_UNIFORM = 0x92EF,
449         GL_TESS_EVALUATION_SUBROUTINE_UNIFORM = 0x92F0,
450         GL_GEOMETRY_SUBROUTINE_UNIFORM    = 0x92F1,
451         GL_FRAGMENT_SUBROUTINE_UNIFORM    = 0x92F2,
452         GL_COMPUTE_SUBROUTINE_UNIFORM     = 0x92F3,
453         GL_TRANSFORM_FEEDBACK_VARYING     = 0x92F4,
454         GL_ACTIVE_RESOURCES               = 0x92F5,
455         GL_MAX_NAME_LENGTH                = 0x92F6,
456         GL_MAX_NUM_ACTIVE_VARIABLES       = 0x92F7,
457         GL_MAX_NUM_COMPATIBLE_SUBROUTINES = 0x92F8,
458         GL_NAME_LENGTH                    = 0x92F9,
459         GL_TYPE                           = 0x92FA,
460         GL_ARRAY_SIZE                     = 0x92FB,
461         GL_OFFSET                         = 0x92FC,
462         GL_BLOCK_INDEX                    = 0x92FD,
463         GL_ARRAY_STRIDE                   = 0x92FE,
464         GL_MATRIX_STRIDE                  = 0x92FF,
465         GL_IS_ROW_MAJOR                   = 0x9300,
466         GL_ATOMIC_COUNTER_BUFFER_INDEX    = 0x9301,
467         GL_BUFFER_BINDING                 = 0x9302,
468         GL_BUFFER_DATA_SIZE               = 0x9303,
469         GL_NUM_ACTIVE_VARIABLES           = 0x9304,
470         GL_ACTIVE_VARIABLES               = 0x9305,
471         GL_REFERENCED_BY_VERTEX_SHADER    = 0x9306,
472         GL_REFERENCED_BY_TESS_CONTROL_SHADER = 0x9307,
473         GL_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x9308,
474         GL_REFERENCED_BY_GEOMETRY_SHADER  = 0x9309,
475         GL_REFERENCED_BY_FRAGMENT_SHADER  = 0x930A,
476         GL_REFERENCED_BY_COMPUTE_SHADER   = 0x930B,
477         GL_TOP_LEVEL_ARRAY_SIZE           = 0x930C,
478         GL_TOP_LEVEL_ARRAY_STRIDE         = 0x930D,
479         GL_LOCATION                       = 0x930E,
480         GL_LOCATION_INDEX                 = 0x930F,
481         GL_IS_PER_PATCH                   = 0x92E7,
482     }
483 
484     extern(System) @nogc nothrow {
485         alias pglGetProgramInterfaceiv = void function(GLuint,GLenum,GLenum,GLint*);
486         alias pglGetProgramResourceIndex = GLuint function(GLuint,GLenum,const(GLchar)*);
487         alias pglGetProgramResourceName = void function(GLuint,GLenum,GLuint,GLsizei,GLsizei*,GLchar*);
488         alias pglGetProgramResourceiv = void function(GLuint,GLenum,GLuint,GLsizei,const(GLenum)*,GLsizei,GLsizei*,GLint*);
489         alias pglGetProgramResourceLocation = GLint function(GLuint,GLenum,const(GLchar)*);
490         alias pglGetProgramResourceLocationIndex = GLint function(GLuint,GLenum,const(GLchar)*);
491     }
492 
493     __gshared {
494         pglGetProgramInterfaceiv glGetProgramInterfaceiv;
495         pglGetProgramResourceIndex glGetProgramResourceIndex;
496         pglGetProgramResourceName glGetProgramResourceName;
497         pglGetProgramResourceiv glGetProgramResourceiv;
498         pglGetProgramResourceLocation glGetProgramResourceLocation;
499         pglGetProgramResourceLocationIndex glGetProgramResourceLocationIndex;
500     }
501 
502     private @nogc nothrow
503     bool loadARBProgramInterfaceQuery(SharedLib lib, GLSupport contextVersion)
504     {
505         lib.bindGLSymbol(cast(void**)&glGetProgramInterfaceiv, "glGetProgramInterfaceiv");
506         lib.bindGLSymbol(cast(void**)&glGetProgramResourceIndex, "glGetProgramResourceIndex");
507         lib.bindGLSymbol(cast(void**)&glGetProgramResourceName, "glGetProgramResourceName");
508         lib.bindGLSymbol(cast(void**)&glGetProgramResourceiv, "glGetProgramResourceiv");
509         lib.bindGLSymbol(cast(void**)&glGetProgramResourceLocation, "glGetProgramResourceLocation");
510         lib.bindGLSymbol(cast(void**)&glGetProgramResourceLocationIndex, "glGetProgramResourceLocationIndex");
511         return resetErrorCountGL();
512     }
513 }
514 else enum hasARBProgramInterfaceQuery = false;
515 
516 // ARB_shader_storage_buffer_object
517 version(GL_ARB) enum useARBShaderStorageBufferObject = true;
518 else version(GL_ARB_shader_storage_buffer_object) enum useARBShaderStorageBufferObject = true;
519 else enum useARBShaderStorageBufferObject = has43;
520 
521 static if(useARBShaderStorageBufferObject) {
522     private bool _hasARBShaderStorageBufferObject;
523     @nogc nothrow bool hasARBShaderStorageBufferObject() { return _hasARBShaderStorageBufferObject; }
524 
525     enum : uint {
526         GL_SHADER_STORAGE_BUFFER          = 0x90D2,
527         GL_SHADER_STORAGE_BUFFER_BINDING  = 0x90D3,
528         GL_SHADER_STORAGE_BUFFER_START    = 0x90D4,
529         GL_SHADER_STORAGE_BUFFER_SIZE     = 0x90D5,
530         GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS = 0x90D6,
531         GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS = 0x90D7,
532         GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS = 0x90D8,
533         GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS = 0x90D9,
534         GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS = 0x90DA,
535         GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS = 0x90DB,
536         GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS = 0x90DC,
537         GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS = 0x90DD,
538         GL_MAX_SHADER_STORAGE_BLOCK_SIZE  = 0x90DE,
539         GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT = 0x90DF,
540         GL_SHADER_STORAGE_BARRIER_BIT     = 0x2000,
541         GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES = 0x8F39,
542     }
543 
544     extern(System) @nogc nothrow alias pglShaderStorageBlockBinding = void function(GLuint,GLuint,GLuint);
545     __gshared pglShaderStorageBlockBinding glShaderStorageBlockBinding;
546 
547     private @nogc nothrow
548     bool loadARBShaderStorageBufferObject(SharedLib lib, GLSupport contextVersion)
549     {
550         lib.bindGLSymbol(cast(void**)&glShaderStorageBlockBinding, "glShaderStorageBlockBinding");
551         return resetErrorCountGL();
552     }
553 }
554 else enum hasARBShaderStorageBufferObject = false;
555 
556 // ARB_stencil_texturing
557 version(GL_ARB) enum useARBStencilTexturing = true;
558 else version(GL_ARB_stencil_texturing) enum useARBStencilTexturing = true;
559 else enum useARBStencilTexturing = has43;
560 
561 static if(useARBStencilTexturing) {
562     private bool _hasARBStencilTexturing;
563     @nogc nothrow bool hasARBStencilTexturing() { return _hasARBStencilTexturing; }
564 
565     enum uint GL_DEPTH_STENCIL_TEXTURE_MODE = 0x90EA;
566 }
567 else enum hasARBStencilTexturing = false;
568 
569 // ARB_texture_buffer_range
570 version(GL_ARB) enum useARBTextureBufferRange = true;
571 else version(GL_ARB_texture_buffer_range) enum useARBTextureBufferRange = true;
572 else enum useARBTextureBufferRange = has43;
573 
574 static if(useARBTextureBufferRange) {
575     private bool _hasARBTextureBufferRange;
576     @nogc nothrow bool hasARBTextureBufferRange() { return _hasARBTextureBufferRange; }
577 
578     enum : uint {
579         GL_TEXTURE_BUFFER_OFFSET = 0x919D,
580         GL_TEXTURE_BUFFER_SIZE = 0x919E,
581         GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT = 0x919F,
582     }
583 
584     extern(System) @nogc nothrow {
585         alias da_glTexBufferRange = void function(GLenum,GLenum,GLuint,GLintptr,GLsizeiptr);
586         alias da_glTextureBufferRangeEXT = void function(GLuint,GLenum,GLenum,GLuint,GLintptr,GLsizeiptr);
587     }
588 
589     __gshared {
590         da_glTexBufferRange glTexBufferRange;
591         da_glTextureBufferRangeEXT glTextureBufferRangeEXT;
592     }
593 
594     private @nogc nothrow
595     bool loadARBTextureBufferRange(SharedLib lib, GLSupport contextVersion)
596     {
597         lib.bindGLSymbol(cast(void**)&glTexBufferRange, "glTexBufferRange");
598 
599         // The previous function is required when loading GL 4.3,
600         // the next one is not. Save the result of resetErrorCountGL and
601         // use that for the return value.
602         bool ret = resetErrorCountGL();
603         if(hasExtension(contextVersion, "GL_EXT_direct_state_access ")) {
604             lib.bindGLSymbol(cast(void**)&glTextureBufferRangeEXT, "glTextureBufferRangeEXT");
605 
606             // Ignore errors.
607             resetErrorCountGL();
608         }
609         return ret;
610     }
611 }
612 else enum hasARBTextureBufferRange = false;
613 
614 // ARB_texture_storage_multisample
615 version(GL_ARB) enum useARBTextureStorageMultisample = true;
616 else version(GL_ARB_texture_storage_multisample) enum useARBTextureStorageMultisample = true;
617 else enum useARBTextureStorageMultisample = has43;
618 
619 static if(useARBTextureStorageMultisample) {
620     private bool _hasARBTextureStorageMultisample;
621     @nogc nothrow bool hasARBTextureStorageMultisample() { return _hasARBTextureStorageMultisample; }
622 
623     extern(System) @nogc nothrow {
624         alias pglTexStorage2DMultisample = void function(GLenum,GLsizei,GLenum,GLsizei,GLsizei,GLboolean);
625         alias pglTexStorage3DMultisample = void function(GLenum,GLsizei,GLenum,GLsizei,GLsizei,GLsizei,GLboolean);
626         alias pglTextureStorage2DMultisampleEXT = void function(GLuint,GLenum,GLsizei,GLenum,GLsizei,GLsizei,GLboolean);
627         alias pglTextureStorage3DMultisampleEXT = void function(GLuint,GLenum,GLsizei,GLenum,GLsizei,GLsizei,GLsizei,GLboolean);
628     }
629 
630     __gshared {
631         pglTexStorage2DMultisample glTexStorage2DMultisample;
632         pglTexStorage3DMultisample glTexStorage3DMultisample;
633         pglTextureStorage2DMultisampleEXT glTextureStorage2DMultisampleEXT;
634         pglTextureStorage3DMultisampleEXT glTextureStorage3DMultisampleEXT;
635     }
636 
637     private @nogc nothrow
638     bool loadARBTextureStorageMultisample(SharedLib lib, GLSupport contextVersion)
639     {
640         lib.bindGLSymbol(cast(void**)&glTexStorage2DMultisample, "glTexStorage2DMultisample");
641         lib.bindGLSymbol(cast(void**)&glTexStorage3DMultisample, "glTexStorage3DMultisample");
642 
643         // The previous two functions are required when loading GL 4.3,
644         // the next two are not. Save the result of resetErrorCountGL and
645         // use that for the return value.
646         bool ret = resetErrorCountGL();
647         if(hasExtension(contextVersion, "GL_EXT_direct_state_access ")) {
648             lib.bindGLSymbol(cast(void**)&glTextureStorage2DMultisampleEXT, "glTextureStorage2DMultisampleEXT");
649             lib.bindGLSymbol(cast(void**)&glTextureStorage3DMultisampleEXT, "glTextureStorage3DMultisampleEXT");
650 
651             // Ignore errors.
652             resetErrorCountGL();
653         }
654         return ret;
655     }
656 }
657 else enum hasARBTextureStorageMultisample = false;
658 
659 // ARB_texture_view
660 version(GL_ARB) enum useARBTextureView = true;
661 else version(GL_ARB_texture_view) enum useARBTextureView = true;
662 else enum useARBTextureView = has43;
663 
664 static if(useARBTextureView) {
665     private bool _hasARBTextureView;
666     @nogc nothrow bool hasARBTextureView() { return _hasARBTextureView; }
667 
668     enum : uint {
669         GL_TEXTURE_VIEW_MIN_LEVEL         = 0x82DB,
670         GL_TEXTURE_VIEW_NUM_LEVELS        = 0x82DC,
671         GL_TEXTURE_VIEW_MIN_LAYER         = 0x82DD,
672         GL_TEXTURE_VIEW_NUM_LAYERS        = 0x82DE,
673         GL_TEXTURE_IMMUTABLE_LEVELS       = 0x82DF,
674     }
675 
676     extern(System) @nogc nothrow alias pglTextureView = void function(GLuint,GLenum,GLuint,GLenum,GLuint,GLuint,GLuint,GLuint);
677     __gshared pglTextureView glTextureView;
678 
679     private @nogc nothrow
680     bool loadARBTextureView(SharedLib lib, GLSupport contextVersion)
681     {
682         lib.bindGLSymbol(cast(void**)&glTextureView, "glTextureView");
683         return resetErrorCountGL();
684     }
685 }
686 else enum hasARBTextureView = false;
687 
688 // ARB_vertex_attrib_binding
689 version(GL_ARB) enum useARBVertexAttribBinding = true;
690 else version(GL_ARB_vertex_attrib_binding) enum useARBVertexAttribBinding = true;
691 else enum useARBVertexAttribBinding = has43;
692 
693 static if(useARBVertexAttribBinding) {
694     private bool _hasARBVertexAttribBinding;
695     @nogc nothrow bool hasARBVertexAttribBinding() { return _hasARBVertexAttribBinding; }
696 
697     enum : uint {
698         GL_VERTEX_ATTRIB_BINDING          = 0x82D4,
699         GL_VERTEX_ATTRIB_RELATIVE_OFFSET  = 0x82D5,
700         GL_VERTEX_BINDING_DIVISOR         = 0x82D6,
701         GL_VERTEX_BINDING_OFFSET          = 0x82D7,
702         GL_VERTEX_BINDING_STRIDE          = 0x82D8,
703         GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET = 0x82D9,
704         GL_MAX_VERTEX_ATTRIB_BINDINGS     = 0x82DA,
705     }
706 
707     extern(System) @nogc nothrow {
708         alias pglBindVertexBuffer = void function(GLuint,GLuint,GLintptr,GLsizei);
709         alias pglVertexAttribFormat = void function(GLuint,GLint,GLenum,GLboolean,GLuint);
710         alias pglVertexAttribIFormat = void function(GLuint,GLint,GLenum,GLuint);
711         alias pglVertexAttribLFormat = void function(GLuint,GLint,GLenum,GLuint);
712         alias pglVertexAttribBinding = void function(GLuint,GLuint);
713         alias pglVertexBindingDivisor = void function(GLuint,GLuint);
714         alias pglVertexArrayBindVertexBufferEXT = void function(GLuint,GLuint,GLuint,GLintptr,GLsizei);
715         alias pglVertexArrayVertexAttribFormatEXT = void function(GLuint,GLuint,GLint,GLenum,GLboolean,GLuint);
716         alias pglVertexArrayVertexAttribIFormatEXT = void function(GLuint,GLuint,GLint,GLenum,GLuint);
717         alias pglVertexArrayVertexAttribLFormatEXT = void function(GLuint,GLuint,GLint,GLenum,GLuint);
718         alias pglVertexArrayVertexAttribBindingEXT = void function(GLuint,GLuint,GLuint);
719         alias pglVertexArrayVertexBindingDivisorEXT = void function(GLuint,GLuint,GLuint);
720     }
721 
722     __gshared {
723         pglBindVertexBuffer glBindVertexBuffer;
724         pglVertexAttribFormat glVertexAttribFormat;
725         pglVertexAttribIFormat glVertexAttribIFormat;
726         pglVertexAttribLFormat glVertexAttribLFormat;
727         pglVertexAttribBinding glVertexAttribBinding;
728         pglVertexBindingDivisor glVertexBindingDivisor;
729         pglVertexArrayBindVertexBufferEXT glVertexArrayBindVertexBufferEXT;
730         pglVertexArrayVertexAttribFormatEXT glVertexArrayVertexAttribFormatEXT;
731         pglVertexArrayVertexAttribIFormatEXT glVertexArrayVertexAttribIFormatEXT;
732         pglVertexArrayVertexAttribLFormatEXT glVertexArrayVertexAttribLFormatEXT;
733         pglVertexArrayVertexAttribBindingEXT glVertexArrayVertexAttribBindingEXT;
734         pglVertexArrayVertexBindingDivisorEXT glVertexArrayVertexBindingDivisorEXT;
735     }
736 
737     private @nogc nothrow
738     bool loadARBVertexAttribBinding(SharedLib lib, GLSupport contextVersion)
739     {
740         lib.bindGLSymbol(cast(void**)&glBindVertexBuffer, "glBindVertexBuffer");
741         lib.bindGLSymbol(cast(void**)&glVertexAttribFormat, "glVertexAttribFormat");
742         lib.bindGLSymbol(cast(void**)&glVertexAttribIFormat, "glVertexAttribIFormat");
743         lib.bindGLSymbol(cast(void**)&glVertexAttribLFormat, "glVertexAttribLFormat");
744         lib.bindGLSymbol(cast(void**)&glVertexAttribBinding, "glVertexAttribBinding");
745         lib.bindGLSymbol(cast(void**)&glVertexBindingDivisor, "glVertexBindingDivisor");
746 
747         // The previous six functions are required when loading GL 4.3,
748         // the next six are not. Save the result of resetErrorCountGL and
749         // use that for the return value.
750         bool ret = resetErrorCountGL();
751         if(hasExtension(contextVersion, "GL_EXT_direct_state_access ")) {
752             lib.bindGLSymbol(cast(void**)&glVertexArrayBindVertexBufferEXT, "glVertexArrayBindVertexBufferEXT");
753             lib.bindGLSymbol(cast(void**)&glVertexArrayVertexAttribFormatEXT, "glVertexArrayVertexAttribFormatEXT");
754             lib.bindGLSymbol(cast(void**)&glVertexArrayVertexAttribIFormatEXT, "glVertexArrayVertexAttribIFormatEXT");
755             lib.bindGLSymbol(cast(void**)&glVertexArrayVertexAttribLFormatEXT, "glVertexArrayVertexAttribLFormatEXT");
756             lib.bindGLSymbol(cast(void**)&glVertexArrayVertexAttribBindingEXT, "glVertexArrayVertexAttribBindingEXT");
757             lib.bindGLSymbol(cast(void**)&glVertexArrayVertexBindingDivisorEXT, "glVertexArrayVertexBindingDivisorEXT");
758             // Ignore errors.
759             resetErrorCountGL();
760         }
761         return ret;
762     }
763 }
764 else enum hasARBVertexAttribBinding = false;
765 
766 // KHR_debug
767 version(GL_ARB) enum useKHRDebug = true;
768 else version(GL_KHR_debug) enum useKHRDebug = true;
769 else enum useKHRDebug = has43;
770 
771 static if(useKHRDebug) {
772     private bool _hasKHRDebug;
773     @nogc nothrow bool hasKHRDebug() { return _hasKHRDebug; }
774 
775     enum : uint {
776         GL_DEBUG_OUTPUT_SYNCHRONOUS       = 0x8242,
777         GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243,
778         GL_DEBUG_CALLBACK_FUNCTION        = 0x8244,
779         GL_DEBUG_CALLBACK_USER_PARAM      = 0x8245,
780         GL_DEBUG_SOURCE_API               = 0x8246,
781         GL_DEBUG_SOURCE_WINDOW_SYSTEM     = 0x8247,
782         GL_DEBUG_SOURCE_SHADER_COMPILER   = 0x8248,
783         GL_DEBUG_SOURCE_THIRD_PARTY       = 0x8249,
784         GL_DEBUG_SOURCE_APPLICATION       = 0x824A,
785         GL_DEBUG_SOURCE_OTHER             = 0x824B,
786         GL_DEBUG_TYPE_ERROR               = 0x824C,
787         GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
788         GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR  = 0x824E,
789         GL_DEBUG_TYPE_PORTABILITY         = 0x824F,
790         GL_DEBUG_TYPE_PERFORMANCE         = 0x8250,
791         GL_DEBUG_TYPE_OTHER               = 0x8251,
792         GL_DEBUG_TYPE_MARKER              = 0x8268,
793         GL_DEBUG_TYPE_PUSH_GROUP          = 0x8269,
794         GL_DEBUG_TYPE_POP_GROUP           = 0x826A,
795         GL_DEBUG_SEVERITY_NOTIFICATION    = 0x826B,
796         GL_MAX_DEBUG_GROUP_STACK_DEPTH    = 0x826C,
797         GL_DEBUG_GROUP_STACK_DEPTH        = 0x826D,
798         GL_BUFFER                         = 0x82E0,
799         GL_SHADER                         = 0x82E1,
800         GL_PROGRAM                        = 0x82E2,
801         GL_QUERY                          = 0x82E3,
802         GL_PROGRAM_PIPELINE               = 0x82E4,
803         GL_SAMPLER                        = 0x82E6,
804         GL_DISPLAY_LIST                   = 0x82E7,
805         GL_MAX_LABEL_LENGTH               = 0x82E8,
806         GL_MAX_DEBUG_MESSAGE_LENGTH       = 0x9143,
807         GL_MAX_DEBUG_LOGGED_MESSAGES      = 0x9144,
808         GL_DEBUG_LOGGED_MESSAGES          = 0x9145,
809         GL_DEBUG_SEVERITY_HIGH            = 0x9146,
810         GL_DEBUG_SEVERITY_MEDIUM          = 0x9147,
811         GL_DEBUG_SEVERITY_LOW             = 0x9148,
812         GL_DEBUG_OUTPUT                   = 0x92E0,
813         GL_CONTEXT_FLAG_DEBUG_BIT         = 0x00000002,
814     }
815 
816     extern(System) nothrow alias GLDEBUGPROC = void function(GLenum,GLenum,GLuint,GLenum,GLsizei,const(GLchar)*,GLvoid*);
817 
818     extern(System) @nogc nothrow {
819         alias pglDebugMessageControl = void function(GLenum,GLenum,GLenum,GLsizei,const(GLuint*),GLboolean);
820         alias pglDebugMessageInsert = void function(GLenum,GLenum,GLuint,GLenum,GLsizei,const(GLchar)*);
821         alias pglDebugMessageCallback = void function(GLDEBUGPROC,const(void)*);
822         alias pglGetDebugMessageLog = GLuint function(GLuint,GLsizei,GLenum*,GLenum*,GLuint*,GLenum*,GLsizei*,GLchar*);
823         alias pglPushDebugGroup = void function(GLenum,GLuint,GLsizei,const(GLchar)*);
824         alias pglPopDebugGroup = void function();
825         alias pglObjectLabel = void function(GLenum,GLuint,GLsizei,const(GLchar)*);
826         alias pglGetObjectLabel = void function(GLenum,GLuint,GLsizei,GLsizei*,GLchar*);
827         alias pglObjectPtrLabel = void function(const(void)*,GLsizei,const(GLchar)*);
828         alias pglGetObjectPtrLabel = void function(const(void)*,GLsizei,GLsizei*,GLchar*);
829     }
830 
831     __gshared {
832         pglDebugMessageControl glDebugMessageControl;
833         pglDebugMessageInsert glDebugMessageInsert;
834         pglDebugMessageCallback glDebugMessageCallback;
835         pglGetDebugMessageLog glGetDebugMessageLog;
836         pglPushDebugGroup glPushDebugGroup;
837         pglPopDebugGroup glPopDebugGroup;
838         pglObjectLabel glObjectLabel;
839         pglGetObjectLabel glGetObjectLabel;
840         pglObjectPtrLabel glObjectPtrLabel;
841         pglGetObjectPtrLabel glGetObjectPtrLabel;
842     }
843 
844     private @nogc nothrow
845     bool loadKHRDebug(SharedLib lib, GLSupport contextVersion)
846     {
847         lib.bindGLSymbol(cast(void**)&glDebugMessageControl, "glDebugMessageControl");
848         lib.bindGLSymbol(cast(void**)&glDebugMessageInsert, "glDebugMessageInsert");
849         lib.bindGLSymbol(cast(void**)&glDebugMessageCallback, "glDebugMessageCallback");
850         lib.bindGLSymbol(cast(void**)&glGetDebugMessageLog, "glGetDebugMessageLog");
851         lib.bindGLSymbol(cast(void**)&glPushDebugGroup, "glPushDebugGroup");
852         lib.bindGLSymbol(cast(void**)&glPopDebugGroup, "glPopDebugGroup");
853         lib.bindGLSymbol(cast(void**)&glObjectLabel, "glObjectLabel");
854         lib.bindGLSymbol(cast(void**)&glGetObjectLabel, "glGetObjectLabel");
855         lib.bindGLSymbol(cast(void**)&glObjectPtrLabel, "glObjectPtrLabel");
856         lib.bindGLSymbol(cast(void**)&glGetObjectPtrLabel, "glGetObjectPtrLabel");
857         return resetErrorCountGL();
858     }
859 }
860 else enum hasKHRDebug = false;
861 
862 package(bindbc.opengl) @nogc nothrow
863 bool loadARB43(SharedLib lib, GLSupport contextVersion)
864 {
865     static if(has43) {
866         if(contextVersion >= GLSupport.gl43) {
867             _hasARBES3Compatibility = true;
868             _hasARBExplicitUniformLocation = true;
869             _hasARBStencilTexturing = true;
870 
871             bool ret = true;
872             ret = _hasARBClearBufferObject = lib.loadARBClearBufferObject(contextVersion);
873             ret = _hasARBComputeShader = lib.loadARBComputeShader(contextVersion);
874             ret = _hasARBCopyImage = lib.loadARBCopyImage(contextVersion);
875             ret = _hasARBFramebufferNoAttachments = lib.loadARBFramebufferNoAttachments(contextVersion);
876             ret = _hasARBInternalFormatQuery2 = lib.loadARBInternalFormatQuery2(contextVersion);
877             ret = _hasARBInvalidateSubdata = lib.loadARBInvalidateSubdata(contextVersion);
878             ret = _hasARBMultiDrawIndirect = lib.loadARBMultiDrawIndirect(contextVersion);
879             ret = _hasARBProgramInterfaceQuery = lib.loadARBProgramInterfaceQuery(contextVersion);
880             ret = _hasARBShaderStorageBufferObject = lib.loadARBShaderStorageBufferObject(contextVersion);
881             ret = _hasARBTextureBufferRange = lib.loadARBTextureBufferRange(contextVersion);
882             ret = _hasARBTextureStorageMultisample = lib.loadARBTextureStorageMultisample(contextVersion);
883             ret = _hasARBTextureView = lib.loadARBTextureView(contextVersion);
884             ret = _hasARBVertexAttribBinding = lib.loadARBVertexAttribBinding(contextVersion);
885             ret = _hasKHRDebug = lib.loadKHRDebug(contextVersion);
886             return ret;
887         }
888     }
889 
890     static if(useARBES3Compatibility) _hasARBES3Compatibility =
891             hasExtension(contextVersion, "GL_ARB_ES3_compatibility");
892 
893     static if(useARBExplicitUniformLocation) _hasARBExplicitUniformLocation =
894             hasExtension(contextVersion, "GL_ARB_explicit_uniform_location");
895 
896     static if(useARBStencilTexturing) _hasARBStencilTexturing =
897             hasExtension(contextVersion, "GL_ARB_stencil_texturing");
898 
899     static if(useARBClearBufferObject) _hasARBClearBufferObject =
900             hasExtension(contextVersion, "GL_ARB_clear_buffer_object") &&
901             lib.loadARBClearBufferObject(contextVersion);
902 
903     static if(useARBComputeShader) _hasARBComputeShader =
904             hasExtension(contextVersion, "GL_ARB_compute_shader") &&
905             lib.loadARBComputeShader(contextVersion);
906 
907     static if(useARBCopyImage) _hasARBCopyImage =
908             hasExtension(contextVersion, "GL_ARB_copy_image") &&
909             lib.loadARBCopyImage(contextVersion);
910 
911     static if(useARBFramebufferNoAttachments) _hasARBFramebufferNoAttachments =
912             hasExtension(contextVersion, "GL_ARB_framebuffer_no_attachments") &&
913             lib.loadARBFramebufferNoAttachments(contextVersion);
914 
915     static if(useARBInternalFormatQuery2) _hasARBInternalFormatQuery2 =
916             hasExtension(contextVersion, "GL_ARB_internalformat_query2") &&
917             lib.loadARBInternalFormatQuery2(contextVersion);
918 
919     static if(useARBInvalidateSubdata) _hasARBInvalidateSubdata =
920             hasExtension(contextVersion, "GL_ARB_invalidate_subdata") &&
921             lib.loadARBInvalidateSubdata(contextVersion);
922 
923     static if(useARBMultiDrawIndirect) _hasARBMultiDrawIndirect =
924             hasExtension(contextVersion, "GL_ARB_multi_draw_indirect") &&
925             lib.loadARBMultiDrawIndirect(contextVersion);
926 
927     static if(useARBProgramInterfaceQuery) _hasARBProgramInterfaceQuery =
928             hasExtension(contextVersion, "GL_ARB_program_interface_query") &&
929             lib.loadARBProgramInterfaceQuery(contextVersion);
930 
931     static if(useARBShaderStorageBufferObject) _hasARBShaderStorageBufferObject =
932             hasExtension(contextVersion, "GL_ARB_shader_storage_buffer_object") &&
933             lib.loadARBShaderStorageBufferObject(contextVersion);
934 
935     static if(useARBTextureBufferRange) _hasARBTextureBufferRange =
936             hasExtension(contextVersion, "GL_ARB_texture_buffer_range") &&
937             lib.loadARBTextureBufferRange(contextVersion);
938 
939     static if(useARBTextureStorageMultisample) _hasARBTextureStorageMultisample =
940             hasExtension(contextVersion, "GL_ARB_texture_storage_multisample") &&
941             lib.loadARBTextureStorageMultisample(contextVersion);
942 
943     static if(useARBTextureView) _hasARBTextureView =
944             hasExtension(contextVersion, "GL_ARB_texture_view") &&
945             lib.loadARBTextureView(contextVersion);
946 
947     static if(useARBVertexAttribBinding) _hasARBVertexAttribBinding =
948             hasExtension(contextVersion, "GL_ARB_vertex_attrib_binding") &&
949             lib.loadARBVertexAttribBinding(contextVersion);
950 
951     static if(useKHRDebug) _hasKHRDebug =
952             hasExtension(contextVersion, "GL_KHR_debug") &&
953             lib.loadKHRDebug(contextVersion);
954 
955     return true;
956 }