siftgl 0.1.0

Memory-safe, ergonomic, zero-dependency, security-hardened OpenGL 3.3-4.6 Core frontend for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
//! Raw OpenGL 3.3–4.6 Core C ABI types, constants, and function pointer typedefs.
//!
//! This module is strictly crate-internal (`pub(crate)`) so raw FFI types and
//! unchecked pointers never leak into the public API surface.

#![allow(
    non_camel_case_types,
    non_snake_case,
    dead_code,
    clippy::upper_case_acronyms
)]

use std::ffi::{c_char, c_double, c_float, c_int, c_uchar, c_uint, c_void};

// ---------------------------------------------------------------------------
// Core OpenGL primitive typedefs (Khronos GL/glcorearb.h)
// ---------------------------------------------------------------------------

pub type GLenum = c_uint;
pub type GLboolean = c_uchar;
pub type GLbitfield = c_uint;
pub type GLbyte = i8;
pub type GLubyte = u8;
pub type GLshort = i16;
pub type GLushort = u16;
pub type GLint = c_int;
pub type GLuint = c_uint;
pub type GLsizei = c_int;
pub type GLfloat = c_float;
pub type GLdouble = c_double;
pub type GLchar = c_char;
pub type GLintptr = isize;
pub type GLsizeiptr = isize;
pub type GLint64 = i64;
pub type GLuint64 = u64;
pub type GLsync = *mut c_void;

pub type GLDEBUGPROC = Option<
    unsafe extern "system" fn(
        source: GLenum,
        gltype: GLenum,
        id: GLuint,
        severity: GLenum,
        length: GLsizei,
        message: *const GLchar,
        user_param: *mut c_void,
    ),
>;

// ---------------------------------------------------------------------------
// Boolean constants
// ---------------------------------------------------------------------------

pub const GL_FALSE: GLboolean = 0;
pub const GL_TRUE: GLboolean = 1;

// ---------------------------------------------------------------------------
// Error codes
// ---------------------------------------------------------------------------

pub const GL_NO_ERROR: GLenum = 0x0000;
pub const GL_INVALID_ENUM: GLenum = 0x0500;
pub const GL_INVALID_VALUE: GLenum = 0x0501;
pub const GL_INVALID_OPERATION: GLenum = 0x0502;
pub const GL_STACK_OVERFLOW: GLenum = 0x0503;
pub const GL_STACK_UNDERFLOW: GLenum = 0x0504;
pub const GL_OUT_OF_MEMORY: GLenum = 0x0505;
pub const GL_INVALID_FRAMEBUFFER_OPERATION: GLenum = 0x0506;
pub const GL_CONTEXT_LOST: GLenum = 0x0507;

// ---------------------------------------------------------------------------
// Clear masks
// ---------------------------------------------------------------------------

pub const GL_DEPTH_BUFFER_BIT: GLbitfield = 0x0000_0100;
pub const GL_STENCIL_BUFFER_BIT: GLbitfield = 0x0000_0400;
pub const GL_COLOR_BUFFER_BIT: GLbitfield = 0x0000_4000;

// ---------------------------------------------------------------------------
// Data types
// ---------------------------------------------------------------------------

pub const GL_BYTE: GLenum = 0x1400;
pub const GL_UNSIGNED_BYTE: GLenum = 0x1401;
pub const GL_SHORT: GLenum = 0x1402;
pub const GL_UNSIGNED_SHORT: GLenum = 0x1403;
pub const GL_INT: GLenum = 0x1404;
pub const GL_UNSIGNED_INT: GLenum = 0x1405;
pub const GL_FLOAT: GLenum = 0x1406;
pub const GL_DOUBLE: GLenum = 0x140A;
pub const GL_HALF_FLOAT: GLenum = 0x140B;

// ---------------------------------------------------------------------------
// Primitive modes
// ---------------------------------------------------------------------------

pub const GL_POINTS: GLenum = 0x0000;
pub const GL_LINES: GLenum = 0x0001;
pub const GL_LINE_LOOP: GLenum = 0x0002;
pub const GL_LINE_STRIP: GLenum = 0x0003;
pub const GL_TRIANGLES: GLenum = 0x0004;
pub const GL_TRIANGLE_STRIP: GLenum = 0x0005;
pub const GL_TRIANGLE_FAN: GLenum = 0x0006;
pub const GL_PATCHES: GLenum = 0x000E;

// ---------------------------------------------------------------------------
// Capabilities & state
// ---------------------------------------------------------------------------

pub const GL_BLEND: GLenum = 0x0BE2;
pub const GL_CULL_FACE: GLenum = 0x0B44;
pub const GL_DEPTH_TEST: GLenum = 0x0B71;
pub const GL_SCISSOR_TEST: GLenum = 0x0C11;
pub const GL_STENCIL_TEST: GLenum = 0x0B90;
pub const GL_MULTISAMPLE: GLenum = 0x809D;
pub const GL_FRAMEBUFFER_SRGB: GLenum = 0x8DB9;
pub const GL_PROGRAM_POINT_SIZE: GLenum = 0x8642;
pub const GL_PRIMITIVE_RESTART: GLenum = 0x8F9D;
pub const GL_TEXTURE_CUBE_MAP_SEAMLESS: GLenum = 0x884F;
pub const GL_DEBUG_OUTPUT: GLenum = 0x92E0;
pub const GL_DEBUG_OUTPUT_SYNCHRONOUS: GLenum = 0x8242;

// ---------------------------------------------------------------------------
// Comparison functions
// ---------------------------------------------------------------------------

pub const GL_NEVER: GLenum = 0x0200;
pub const GL_LESS: GLenum = 0x0201;
pub const GL_EQUAL: GLenum = 0x0202;
pub const GL_LEQUAL: GLenum = 0x0203;
pub const GL_GREATER: GLenum = 0x0204;
pub const GL_NOTEQUAL: GLenum = 0x0205;
pub const GL_GEQUAL: GLenum = 0x0206;
pub const GL_ALWAYS: GLenum = 0x0207;

// ---------------------------------------------------------------------------
// Blend factors & equations
// ---------------------------------------------------------------------------

pub const GL_ZERO: GLenum = 0;
pub const GL_ONE: GLenum = 1;
pub const GL_SRC_COLOR: GLenum = 0x0300;
pub const GL_ONE_MINUS_SRC_COLOR: GLenum = 0x0301;
pub const GL_SRC_ALPHA: GLenum = 0x0302;
pub const GL_ONE_MINUS_SRC_ALPHA: GLenum = 0x0303;
pub const GL_DST_ALPHA: GLenum = 0x0304;
pub const GL_ONE_MINUS_DST_ALPHA: GLenum = 0x0305;
pub const GL_DST_COLOR: GLenum = 0x0306;
pub const GL_ONE_MINUS_DST_COLOR: GLenum = 0x0307;
pub const GL_SRC_ALPHA_SATURATE: GLenum = 0x0308;
pub const GL_CONSTANT_COLOR: GLenum = 0x8001;
pub const GL_ONE_MINUS_CONSTANT_COLOR: GLenum = 0x8002;
pub const GL_CONSTANT_ALPHA: GLenum = 0x8003;
pub const GL_ONE_MINUS_CONSTANT_ALPHA: GLenum = 0x8004;

pub const GL_FUNC_ADD: GLenum = 0x8006;
pub const GL_MIN: GLenum = 0x8007;
pub const GL_MAX: GLenum = 0x8008;
pub const GL_FUNC_SUBTRACT: GLenum = 0x800A;
pub const GL_FUNC_REVERSE_SUBTRACT: GLenum = 0x800B;

// ---------------------------------------------------------------------------
// Rasterizer state
// ---------------------------------------------------------------------------

pub const GL_FRONT: GLenum = 0x0404;
pub const GL_BACK: GLenum = 0x0405;
pub const GL_FRONT_AND_BACK: GLenum = 0x0408;
pub const GL_CW: GLenum = 0x0900;
pub const GL_CCW: GLenum = 0x0901;
pub const GL_POINT: GLenum = 0x1B00;
pub const GL_LINE: GLenum = 0x1B01;
pub const GL_FILL: GLenum = 0x1B02;

// ---------------------------------------------------------------------------
// String / context info queries
// ---------------------------------------------------------------------------

pub const GL_VENDOR: GLenum = 0x1F00;
pub const GL_RENDERER: GLenum = 0x1F01;
pub const GL_VERSION: GLenum = 0x1F02;
pub const GL_EXTENSIONS: GLenum = 0x1F03;
pub const GL_SHADING_LANGUAGE_VERSION: GLenum = 0x8B8C;
pub const GL_MAJOR_VERSION: GLenum = 0x821B;
pub const GL_MINOR_VERSION: GLenum = 0x821C;
pub const GL_NUM_EXTENSIONS: GLenum = 0x821D;
pub const GL_CONTEXT_PROFILE_MASK: GLenum = 0x9126;
pub const GL_CONTEXT_CORE_PROFILE_BIT: GLint = 0x0000_0001;
pub const GL_CONTEXT_COMPATIBILITY_PROFILE_BIT: GLint = 0x0000_0002;
pub const GL_MAX_TEXTURE_IMAGE_UNITS: GLenum = 0x8872;
pub const GL_MAX_VERTEX_ATTRIBS: GLenum = 0x8869;
pub const GL_MAX_COLOR_ATTACHMENTS: GLenum = 0x8CDF;
pub const GL_PACK_ALIGNMENT: GLenum = 0x0D05;
pub const GL_UNPACK_ALIGNMENT: GLenum = 0x0CF5;

// ---------------------------------------------------------------------------
// Buffer targets, usage, mapping, and storage flags
// ---------------------------------------------------------------------------

pub const GL_ARRAY_BUFFER: GLenum = 0x8892;
pub const GL_ELEMENT_ARRAY_BUFFER: GLenum = 0x8893;
pub const GL_PIXEL_PACK_BUFFER: GLenum = 0x88EB;
pub const GL_PIXEL_UNPACK_BUFFER: GLenum = 0x88EC;
pub const GL_UNIFORM_BUFFER: GLenum = 0x8A11;
pub const GL_TEXTURE_BUFFER: GLenum = 0x8C2A;
pub const GL_TRANSFORM_FEEDBACK_BUFFER: GLenum = 0x8C8E;
pub const GL_COPY_READ_BUFFER: GLenum = 0x8F36;
pub const GL_COPY_WRITE_BUFFER: GLenum = 0x8F37;
pub const GL_DRAW_INDIRECT_BUFFER: GLenum = 0x8F3F;
pub const GL_SHADER_STORAGE_BUFFER: GLenum = 0x90D2;
pub const GL_DISPATCH_INDIRECT_BUFFER: GLenum = 0x90EE;
pub const GL_QUERY_BUFFER: GLenum = 0x9192;
pub const GL_ATOMIC_COUNTER_BUFFER: GLenum = 0x92C0;

pub const GL_STREAM_DRAW: GLenum = 0x88E0;
pub const GL_STREAM_READ: GLenum = 0x88E1;
pub const GL_STREAM_COPY: GLenum = 0x88E2;
pub const GL_STATIC_DRAW: GLenum = 0x88E4;
pub const GL_STATIC_READ: GLenum = 0x88E5;
pub const GL_STATIC_COPY: GLenum = 0x88E6;
pub const GL_DYNAMIC_DRAW: GLenum = 0x88E8;
pub const GL_DYNAMIC_READ: GLenum = 0x88E9;
pub const GL_DYNAMIC_COPY: GLenum = 0x88EA;

pub const GL_MAP_READ_BIT: GLbitfield = 0x0001;
pub const GL_MAP_WRITE_BIT: GLbitfield = 0x0002;
pub const GL_MAP_INVALIDATE_RANGE_BIT: GLbitfield = 0x0004;
pub const GL_MAP_INVALIDATE_BUFFER_BIT: GLbitfield = 0x0008;
pub const GL_MAP_FLUSH_EXPLICIT_BIT: GLbitfield = 0x0010;
pub const GL_MAP_UNSYNCHRONIZED_BIT: GLbitfield = 0x0020;
pub const GL_MAP_PERSISTENT_BIT: GLbitfield = 0x0040;
pub const GL_MAP_COHERENT_BIT: GLbitfield = 0x0080;
pub const GL_DYNAMIC_STORAGE_BIT: GLbitfield = 0x0100;
pub const GL_CLIENT_STORAGE_BIT: GLbitfield = 0x0200;

// ---------------------------------------------------------------------------
// Shaders & programs
// ---------------------------------------------------------------------------

pub const GL_FRAGMENT_SHADER: GLenum = 0x8B30;
pub const GL_VERTEX_SHADER: GLenum = 0x8B31;
pub const GL_GEOMETRY_SHADER: GLenum = 0x8DD9;
pub const GL_TESS_EVALUATION_SHADER: GLenum = 0x8E87;
pub const GL_TESS_CONTROL_SHADER: GLenum = 0x8E88;
pub const GL_COMPUTE_SHADER: GLenum = 0x91B9;

pub const GL_DELETE_STATUS: GLenum = 0x8B80;
pub const GL_COMPILE_STATUS: GLenum = 0x8B81;
pub const GL_LINK_STATUS: GLenum = 0x8B82;
pub const GL_VALIDATE_STATUS: GLenum = 0x8B83;
pub const GL_INFO_LOG_LENGTH: GLenum = 0x8B84;
pub const GL_ACTIVE_UNIFORMS: GLenum = 0x8B86;
pub const GL_ACTIVE_UNIFORM_MAX_LENGTH: GLenum = 0x8B87;
pub const GL_ACTIVE_ATTRIBUTES: GLenum = 0x8B89;
pub const GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: GLenum = 0x8B8A;
pub const GL_INVALID_INDEX: GLuint = 0xFFFF_FFFF;

// ---------------------------------------------------------------------------
// Textures & samplers
// ---------------------------------------------------------------------------

pub const GL_TEXTURE0: GLenum = 0x84C0;
pub const GL_TEXTURE_1D: GLenum = 0x0DE0;
pub const GL_TEXTURE_2D: GLenum = 0x0DE1;
pub const GL_TEXTURE_3D: GLenum = 0x806F;
pub const GL_TEXTURE_CUBE_MAP: GLenum = 0x8513;
pub const GL_TEXTURE_2D_ARRAY: GLenum = 0x8C1A;
pub const GL_TEXTURE_2D_MULTISAMPLE: GLenum = 0x9100;

pub const GL_TEXTURE_MAG_FILTER: GLenum = 0x2800;
pub const GL_TEXTURE_MIN_FILTER: GLenum = 0x2801;
pub const GL_TEXTURE_WRAP_S: GLenum = 0x2802;
pub const GL_TEXTURE_WRAP_T: GLenum = 0x2803;
pub const GL_TEXTURE_WRAP_R: GLenum = 0x8072;
pub const GL_TEXTURE_COMPARE_MODE: GLenum = 0x884C;
pub const GL_TEXTURE_COMPARE_FUNC: GLenum = 0x884D;
pub const GL_COMPARE_REF_TO_TEXTURE: GLenum = 0x884E;
pub const GL_NONE: GLenum = 0;
pub const GL_TEXTURE_MAX_ANISOTROPY: GLenum = 0x84FE;
pub const GL_TEXTURE_MIN_LOD: GLenum = 0x813A;
pub const GL_TEXTURE_MAX_LOD: GLenum = 0x813B;
pub const GL_TEXTURE_LOD_BIAS: GLenum = 0x8501;

pub const GL_NEAREST: GLenum = 0x2600;
pub const GL_LINEAR: GLenum = 0x2601;
pub const GL_NEAREST_MIPMAP_NEAREST: GLenum = 0x2700;
pub const GL_LINEAR_MIPMAP_NEAREST: GLenum = 0x2701;
pub const GL_NEAREST_MIPMAP_LINEAR: GLenum = 0x2702;
pub const GL_LINEAR_MIPMAP_LINEAR: GLenum = 0x2703;

pub const GL_REPEAT: GLenum = 0x2901;
pub const GL_CLAMP_TO_EDGE: GLenum = 0x812F;
pub const GL_CLAMP_TO_BORDER: GLenum = 0x812D;
pub const GL_MIRRORED_REPEAT: GLenum = 0x8370;

// Pixel formats & internal formats
pub const GL_RED: GLenum = 0x1903;
pub const GL_RG: GLenum = 0x8227;
pub const GL_RGB: GLenum = 0x1907;
pub const GL_RGBA: GLenum = 0x1908;
pub const GL_BGR: GLenum = 0x80E0;
pub const GL_BGRA: GLenum = 0x80E1;
pub const GL_DEPTH_COMPONENT: GLenum = 0x1902;
pub const GL_DEPTH_STENCIL: GLenum = 0x84F9;

pub const GL_R8: GLenum = 0x8229;
pub const GL_RG8: GLenum = 0x822B;
pub const GL_RGB8: GLenum = 0x8051;
pub const GL_RGBA8: GLenum = 0x8058;
pub const GL_SRGB8: GLenum = 0x8C41;
pub const GL_SRGB8_ALPHA8: GLenum = 0x8C43;
pub const GL_R16F: GLenum = 0x822D;
pub const GL_RG16F: GLenum = 0x822F;
pub const GL_RGB16F: GLenum = 0x881B;
pub const GL_RGBA16F: GLenum = 0x881A;
pub const GL_R32F: GLenum = 0x822E;
pub const GL_RG32F: GLenum = 0x8230;
pub const GL_RGB32F: GLenum = 0x8815;
pub const GL_RGBA32F: GLenum = 0x8814;
pub const GL_R32UI: GLenum = 0x8236;
pub const GL_RGBA32UI: GLenum = 0x8D70;
pub const GL_DEPTH_COMPONENT16: GLenum = 0x81A5;
pub const GL_DEPTH_COMPONENT24: GLenum = 0x81A6;
pub const GL_DEPTH_COMPONENT32F: GLenum = 0x8CAC;
pub const GL_DEPTH24_STENCIL8: GLenum = 0x88F0;
pub const GL_DEPTH32F_STENCIL8: GLenum = 0x8CAD;

// ---------------------------------------------------------------------------
// Framebuffers & renderbuffers
// ---------------------------------------------------------------------------

pub const GL_FRAMEBUFFER: GLenum = 0x8D40;
pub const GL_READ_FRAMEBUFFER: GLenum = 0x8CA8;
pub const GL_DRAW_FRAMEBUFFER: GLenum = 0x8CA9;
pub const GL_RENDERBUFFER: GLenum = 0x8D41;

pub const GL_COLOR_ATTACHMENT0: GLenum = 0x8CE0;
pub const GL_DEPTH_ATTACHMENT: GLenum = 0x8D00;
pub const GL_STENCIL_ATTACHMENT: GLenum = 0x8D20;
pub const GL_DEPTH_STENCIL_ATTACHMENT: GLenum = 0x821A;

pub const GL_FRAMEBUFFER_COMPLETE: GLenum = 0x8CD5;
pub const GL_FRAMEBUFFER_UNDEFINED: GLenum = 0x8219;
pub const GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLenum = 0x8CD6;
pub const GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLenum = 0x8CD7;
pub const GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: GLenum = 0x8CDB;
pub const GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: GLenum = 0x8CDC;
pub const GL_FRAMEBUFFER_UNSUPPORTED: GLenum = 0x8CDD;
pub const GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: GLenum = 0x8D56;
pub const GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: GLenum = 0x8DA8;

// ---------------------------------------------------------------------------
// Memory barriers
// ---------------------------------------------------------------------------

pub const GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT: GLbitfield = 0x0000_0001;
pub const GL_ELEMENT_ARRAY_BARRIER_BIT: GLbitfield = 0x0000_0002;
pub const GL_UNIFORM_BARRIER_BIT: GLbitfield = 0x0000_0004;
pub const GL_TEXTURE_FETCH_BARRIER_BIT: GLbitfield = 0x0000_0008;
pub const GL_SHADER_IMAGE_ACCESS_BARRIER_BIT: GLbitfield = 0x0000_0020;
pub const GL_COMMAND_BARRIER_BIT: GLbitfield = 0x0000_0040;
pub const GL_PIXEL_BUFFER_BARRIER_BIT: GLbitfield = 0x0000_0080;
pub const GL_TEXTURE_UPDATE_BARRIER_BIT: GLbitfield = 0x0000_0100;
pub const GL_BUFFER_UPDATE_BARRIER_BIT: GLbitfield = 0x0000_0200;
pub const GL_FRAMEBUFFER_BARRIER_BIT: GLbitfield = 0x0000_0400;
pub const GL_TRANSFORM_FEEDBACK_BARRIER_BIT: GLbitfield = 0x0000_0800;
pub const GL_ATOMIC_COUNTER_BARRIER_BIT: GLbitfield = 0x0000_1000;
pub const GL_SHADER_STORAGE_BARRIER_BIT: GLbitfield = 0x0000_2000;
pub const GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT: GLbitfield = 0x0000_4000;
pub const GL_ALL_BARRIER_BITS: GLbitfield = 0xFFFF_FFFF;

// ---------------------------------------------------------------------------
// Sync & queries
// ---------------------------------------------------------------------------

pub const GL_SYNC_GPU_COMMANDS_COMPLETE: GLenum = 0x9117;
pub const GL_SYNC_FLUSH_COMMANDS_BIT: GLbitfield = 0x0000_0001;
pub const GL_ALREADY_SIGNALED: GLenum = 0x911A;
pub const GL_TIMEOUT_EXPIRED: GLenum = 0x911B;
pub const GL_CONDITION_SATISFIED: GLenum = 0x911C;
pub const GL_WAIT_FAILED: GLenum = 0x911D;
pub const GL_TIMEOUT_IGNORED: GLuint64 = 0xFFFF_FFFF_FFFF_FFFF;

pub const GL_SAMPLES_PASSED: GLenum = 0x8914;
pub const GL_ANY_SAMPLES_PASSED: GLenum = 0x8C2F;
pub const GL_PRIMITIVES_GENERATED: GLenum = 0x8C87;
pub const GL_TIME_ELAPSED: GLenum = 0x88BF;
pub const GL_TIMESTAMP: GLenum = 0x8E28;
pub const GL_QUERY_RESULT: GLenum = 0x8866;
pub const GL_QUERY_RESULT_AVAILABLE: GLenum = 0x8867;

// ---------------------------------------------------------------------------
// Debug output (GL 4.3 / KHR_debug)
// ---------------------------------------------------------------------------

pub const GL_DONT_CARE: GLenum = 0x1100;
pub const GL_DEBUG_SOURCE_API: GLenum = 0x8246;
pub const GL_DEBUG_SOURCE_WINDOW_SYSTEM: GLenum = 0x8247;
pub const GL_DEBUG_SOURCE_SHADER_COMPILER: GLenum = 0x8248;
pub const GL_DEBUG_SOURCE_THIRD_PARTY: GLenum = 0x8249;
pub const GL_DEBUG_SOURCE_APPLICATION: GLenum = 0x824A;
pub const GL_DEBUG_SOURCE_OTHER: GLenum = 0x824B;

pub const GL_DEBUG_TYPE_ERROR: GLenum = 0x824C;
pub const GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: GLenum = 0x824D;
pub const GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: GLenum = 0x824E;
pub const GL_DEBUG_TYPE_PORTABILITY: GLenum = 0x824F;
pub const GL_DEBUG_TYPE_PERFORMANCE: GLenum = 0x8250;
pub const GL_DEBUG_TYPE_OTHER: GLenum = 0x8251;
pub const GL_DEBUG_TYPE_MARKER: GLenum = 0x8268;

pub const GL_DEBUG_SEVERITY_HIGH: GLenum = 0x9146;
pub const GL_DEBUG_SEVERITY_MEDIUM: GLenum = 0x9147;
pub const GL_DEBUG_SEVERITY_LOW: GLenum = 0x9148;
pub const GL_DEBUG_SEVERITY_NOTIFICATION: GLenum = 0x826B;

// ---------------------------------------------------------------------------
// Function pointer typedefs (extern "system" matches APIENTRY / WINAPI)
// ---------------------------------------------------------------------------

pub type PFN_glGetError = unsafe extern "system" fn() -> GLenum;
pub type PFN_glGetString = unsafe extern "system" fn(name: GLenum) -> *const GLubyte;
pub type PFN_glGetStringi = unsafe extern "system" fn(name: GLenum, index: GLuint) -> *const GLubyte;
pub type PFN_glGetIntegerv = unsafe extern "system" fn(pname: GLenum, data: *mut GLint);
pub type PFN_glGetFloatv = unsafe extern "system" fn(pname: GLenum, data: *mut GLfloat);
pub type PFN_glFlush = unsafe extern "system" fn();
pub type PFN_glFinish = unsafe extern "system" fn();
pub type PFN_glPixelStorei = unsafe extern "system" fn(pname: GLenum, param: GLint);
pub type PFN_glReadPixels = unsafe extern "system" fn(
    x: GLint,
    y: GLint,
    width: GLsizei,
    height: GLsizei,
    format: GLenum,
    gltype: GLenum,
    pixels: *mut c_void,
);

// State
pub type PFN_glViewport =
    unsafe extern "system" fn(x: GLint, y: GLint, width: GLsizei, height: GLsizei);
pub type PFN_glScissor =
    unsafe extern "system" fn(x: GLint, y: GLint, width: GLsizei, height: GLsizei);
pub type PFN_glClearColor =
    unsafe extern "system" fn(red: GLfloat, green: GLfloat, blue: GLfloat, alpha: GLfloat);
pub type PFN_glClearDepth = unsafe extern "system" fn(depth: GLdouble);
pub type PFN_glClear = unsafe extern "system" fn(mask: GLbitfield);
pub type PFN_glEnable = unsafe extern "system" fn(cap: GLenum);
pub type PFN_glDisable = unsafe extern "system" fn(cap: GLenum);
pub type PFN_glIsEnabled = unsafe extern "system" fn(cap: GLenum) -> GLboolean;
pub type PFN_glBlendFunc = unsafe extern "system" fn(sfactor: GLenum, dfactor: GLenum);
pub type PFN_glBlendFuncSeparate = unsafe extern "system" fn(
    sfactor_rgb: GLenum,
    dfactor_rgb: GLenum,
    sfactor_alpha: GLenum,
    dfactor_alpha: GLenum,
);
pub type PFN_glBlendEquation = unsafe extern "system" fn(mode: GLenum);
pub type PFN_glDepthFunc = unsafe extern "system" fn(func: GLenum);
pub type PFN_glDepthMask = unsafe extern "system" fn(flag: GLboolean);
pub type PFN_glColorMask = unsafe extern "system" fn(
    red: GLboolean,
    green: GLboolean,
    blue: GLboolean,
    alpha: GLboolean,
);
pub type PFN_glCullFace = unsafe extern "system" fn(mode: GLenum);
pub type PFN_glFrontFace = unsafe extern "system" fn(mode: GLenum);
pub type PFN_glPolygonMode = unsafe extern "system" fn(face: GLenum, mode: GLenum);

// Draw & compute
pub type PFN_glDrawArrays =
    unsafe extern "system" fn(mode: GLenum, first: GLint, count: GLsizei);
pub type PFN_glDrawElements = unsafe extern "system" fn(
    mode: GLenum,
    count: GLsizei,
    gltype: GLenum,
    indices: *const c_void,
);
pub type PFN_glDrawArraysInstanced = unsafe extern "system" fn(
    mode: GLenum,
    first: GLint,
    count: GLsizei,
    instancecount: GLsizei,
);
pub type PFN_glDrawElementsInstanced = unsafe extern "system" fn(
    mode: GLenum,
    count: GLsizei,
    gltype: GLenum,
    indices: *const c_void,
    instancecount: GLsizei,
);
pub type PFN_glDispatchCompute = unsafe extern "system" fn(
    num_groups_x: GLuint,
    num_groups_y: GLuint,
    num_groups_z: GLuint,
);
pub type PFN_glMemoryBarrier = unsafe extern "system" fn(barriers: GLbitfield);

// Buffers
pub type PFN_glGenBuffers = unsafe extern "system" fn(n: GLsizei, buffers: *mut GLuint);
pub type PFN_glDeleteBuffers = unsafe extern "system" fn(n: GLsizei, buffers: *const GLuint);
pub type PFN_glBindBuffer = unsafe extern "system" fn(target: GLenum, buffer: GLuint);
pub type PFN_glBindBufferBase =
    unsafe extern "system" fn(target: GLenum, index: GLuint, buffer: GLuint);
pub type PFN_glBindBufferRange = unsafe extern "system" fn(
    target: GLenum,
    index: GLuint,
    buffer: GLuint,
    offset: GLintptr,
    size: GLsizeiptr,
);
pub type PFN_glBufferData = unsafe extern "system" fn(
    target: GLenum,
    size: GLsizeiptr,
    data: *const c_void,
    usage: GLenum,
);
pub type PFN_glBufferSubData = unsafe extern "system" fn(
    target: GLenum,
    offset: GLintptr,
    size: GLsizeiptr,
    data: *const c_void,
);
pub type PFN_glGetBufferSubData = unsafe extern "system" fn(
    target: GLenum,
    offset: GLintptr,
    size: GLsizeiptr,
    data: *mut c_void,
);
pub type PFN_glCopyBufferSubData = unsafe extern "system" fn(
    read_target: GLenum,
    write_target: GLenum,
    read_offset: GLintptr,
    write_offset: GLintptr,
    size: GLsizeiptr,
);
pub type PFN_glMapBufferRange = unsafe extern "system" fn(
    target: GLenum,
    offset: GLintptr,
    length: GLsizeiptr,
    access: GLbitfield,
) -> *mut c_void;
pub type PFN_glUnmapBuffer = unsafe extern "system" fn(target: GLenum) -> GLboolean;
pub type PFN_glFlushMappedBufferRange =
    unsafe extern "system" fn(target: GLenum, offset: GLintptr, length: GLsizeiptr);
pub type PFN_glBufferStorage = unsafe extern "system" fn(
    target: GLenum,
    size: GLsizeiptr,
    data: *const c_void,
    flags: GLbitfield,
);

// Vertex arrays
pub type PFN_glGenVertexArrays = unsafe extern "system" fn(n: GLsizei, arrays: *mut GLuint);
pub type PFN_glDeleteVertexArrays = unsafe extern "system" fn(n: GLsizei, arrays: *const GLuint);
pub type PFN_glBindVertexArray = unsafe extern "system" fn(array: GLuint);
pub type PFN_glEnableVertexAttribArray = unsafe extern "system" fn(index: GLuint);
pub type PFN_glDisableVertexAttribArray = unsafe extern "system" fn(index: GLuint);
pub type PFN_glVertexAttribPointer = unsafe extern "system" fn(
    index: GLuint,
    size: GLint,
    gltype: GLenum,
    normalized: GLboolean,
    stride: GLsizei,
    pointer: *const c_void,
);
pub type PFN_glVertexAttribIPointer = unsafe extern "system" fn(
    index: GLuint,
    size: GLint,
    gltype: GLenum,
    stride: GLsizei,
    pointer: *const c_void,
);
pub type PFN_glVertexAttribDivisor = unsafe extern "system" fn(index: GLuint, divisor: GLuint);

// Shaders & programs
pub type PFN_glCreateShader = unsafe extern "system" fn(shader_type: GLenum) -> GLuint;
pub type PFN_glDeleteShader = unsafe extern "system" fn(shader: GLuint);
pub type PFN_glShaderSource = unsafe extern "system" fn(
    shader: GLuint,
    count: GLsizei,
    string: *const *const GLchar,
    length: *const GLint,
);
pub type PFN_glCompileShader = unsafe extern "system" fn(shader: GLuint);
pub type PFN_glGetShaderiv =
    unsafe extern "system" fn(shader: GLuint, pname: GLenum, params: *mut GLint);
pub type PFN_glGetShaderInfoLog = unsafe extern "system" fn(
    shader: GLuint,
    max_length: GLsizei,
    length: *mut GLsizei,
    info_log: *mut GLchar,
);

pub type PFN_glCreateProgram = unsafe extern "system" fn() -> GLuint;
pub type PFN_glDeleteProgram = unsafe extern "system" fn(program: GLuint);
pub type PFN_glAttachShader = unsafe extern "system" fn(program: GLuint, shader: GLuint);
pub type PFN_glDetachShader = unsafe extern "system" fn(program: GLuint, shader: GLuint);
pub type PFN_glLinkProgram = unsafe extern "system" fn(program: GLuint);
pub type PFN_glValidateProgram = unsafe extern "system" fn(program: GLuint);
pub type PFN_glUseProgram = unsafe extern "system" fn(program: GLuint);
pub type PFN_glGetProgramiv =
    unsafe extern "system" fn(program: GLuint, pname: GLenum, params: *mut GLint);
pub type PFN_glGetProgramInfoLog = unsafe extern "system" fn(
    program: GLuint,
    max_length: GLsizei,
    length: *mut GLsizei,
    info_log: *mut GLchar,
);
pub type PFN_glGetUniformLocation =
    unsafe extern "system" fn(program: GLuint, name: *const GLchar) -> GLint;
pub type PFN_glGetAttribLocation =
    unsafe extern "system" fn(program: GLuint, name: *const GLchar) -> GLint;
pub type PFN_glGetUniformBlockIndex =
    unsafe extern "system" fn(program: GLuint, uniform_block_name: *const GLchar) -> GLuint;
pub type PFN_glUniformBlockBinding = unsafe extern "system" fn(
    program: GLuint,
    uniform_block_index: GLuint,
    uniform_block_binding: GLuint,
);
pub type PFN_glGetActiveUniform = unsafe extern "system" fn(
    program: GLuint,
    index: GLuint,
    buf_size: GLsizei,
    length: *mut GLsizei,
    size: *mut GLint,
    gltype: *mut GLenum,
    name: *mut GLchar,
);
pub type PFN_glGetActiveAttrib = unsafe extern "system" fn(
    program: GLuint,
    index: GLuint,
    buf_size: GLsizei,
    length: *mut GLsizei,
    size: *mut GLint,
    gltype: *mut GLenum,
    name: *mut GLchar,
);

pub type PFN_glUniform1i = unsafe extern "system" fn(location: GLint, v0: GLint);
pub type PFN_glUniform1ui = unsafe extern "system" fn(location: GLint, v0: GLuint);
pub type PFN_glUniform1f = unsafe extern "system" fn(location: GLint, v0: GLfloat);
pub type PFN_glUniform2f =
    unsafe extern "system" fn(location: GLint, v0: GLfloat, v1: GLfloat);
pub type PFN_glUniform3f =
    unsafe extern "system" fn(location: GLint, v0: GLfloat, v1: GLfloat, v2: GLfloat);
pub type PFN_glUniform4f = unsafe extern "system" fn(
    location: GLint,
    v0: GLfloat,
    v1: GLfloat,
    v2: GLfloat,
    v3: GLfloat,
);
pub type PFN_glUniformMatrix3fv = unsafe extern "system" fn(
    location: GLint,
    count: GLsizei,
    transpose: GLboolean,
    value: *const GLfloat,
);
pub type PFN_glUniformMatrix4fv = unsafe extern "system" fn(
    location: GLint,
    count: GLsizei,
    transpose: GLboolean,
    value: *const GLfloat,
);

// Textures & samplers
pub type PFN_glGenTextures = unsafe extern "system" fn(n: GLsizei, textures: *mut GLuint);
pub type PFN_glDeleteTextures = unsafe extern "system" fn(n: GLsizei, textures: *const GLuint);
pub type PFN_glBindTexture = unsafe extern "system" fn(target: GLenum, texture: GLuint);
pub type PFN_glActiveTexture = unsafe extern "system" fn(texture: GLenum);
pub type PFN_glTexImage2D = unsafe extern "system" fn(
    target: GLenum,
    level: GLint,
    internalformat: GLint,
    width: GLsizei,
    height: GLsizei,
    border: GLint,
    format: GLenum,
    gltype: GLenum,
    data: *const c_void,
);
pub type PFN_glTexSubImage2D = unsafe extern "system" fn(
    target: GLenum,
    level: GLint,
    xoffset: GLint,
    yoffset: GLint,
    width: GLsizei,
    height: GLsizei,
    format: GLenum,
    gltype: GLenum,
    data: *const c_void,
);
pub type PFN_glTexParameteri =
    unsafe extern "system" fn(target: GLenum, pname: GLenum, param: GLint);
pub type PFN_glTexParameterf =
    unsafe extern "system" fn(target: GLenum, pname: GLenum, param: GLfloat);
pub type PFN_glGenerateMipmap = unsafe extern "system" fn(target: GLenum);

pub type PFN_glGenSamplers = unsafe extern "system" fn(count: GLsizei, samplers: *mut GLuint);
pub type PFN_glDeleteSamplers = unsafe extern "system" fn(count: GLsizei, samplers: *const GLuint);
pub type PFN_glBindSampler = unsafe extern "system" fn(unit: GLuint, sampler: GLuint);
pub type PFN_glSamplerParameteri =
    unsafe extern "system" fn(sampler: GLuint, pname: GLenum, param: GLint);
pub type PFN_glSamplerParameterf =
    unsafe extern "system" fn(sampler: GLuint, pname: GLenum, param: GLfloat);

// Framebuffers & renderbuffers
pub type PFN_glGenFramebuffers = unsafe extern "system" fn(n: GLsizei, ids: *mut GLuint);
pub type PFN_glDeleteFramebuffers = unsafe extern "system" fn(n: GLsizei, ids: *const GLuint);
pub type PFN_glBindFramebuffer = unsafe extern "system" fn(target: GLenum, framebuffer: GLuint);
pub type PFN_glFramebufferTexture2D = unsafe extern "system" fn(
    target: GLenum,
    attachment: GLenum,
    textarget: GLenum,
    texture: GLuint,
    level: GLint,
);
pub type PFN_glFramebufferRenderbuffer = unsafe extern "system" fn(
    target: GLenum,
    attachment: GLenum,
    renderbuffertarget: GLenum,
    renderbuffer: GLuint,
);
pub type PFN_glCheckFramebufferStatus = unsafe extern "system" fn(target: GLenum) -> GLenum;
pub type PFN_glDrawBuffers = unsafe extern "system" fn(n: GLsizei, bufs: *const GLenum);
pub type PFN_glBlitFramebuffer = unsafe extern "system" fn(
    src_x0: GLint,
    src_y0: GLint,
    src_x1: GLint,
    src_y1: GLint,
    dst_x0: GLint,
    dst_y0: GLint,
    dst_x1: GLint,
    dst_y1: GLint,
    mask: GLbitfield,
    filter: GLenum,
);

pub type PFN_glGenRenderbuffers = unsafe extern "system" fn(n: GLsizei, ids: *mut GLuint);
pub type PFN_glDeleteRenderbuffers = unsafe extern "system" fn(n: GLsizei, ids: *const GLuint);
pub type PFN_glBindRenderbuffer =
    unsafe extern "system" fn(target: GLenum, renderbuffer: GLuint);
pub type PFN_glRenderbufferStorage = unsafe extern "system" fn(
    target: GLenum,
    internalformat: GLenum,
    width: GLsizei,
    height: GLsizei,
);
pub type PFN_glRenderbufferStorageMultisample = unsafe extern "system" fn(
    target: GLenum,
    samples: GLsizei,
    internalformat: GLenum,
    width: GLsizei,
    height: GLsizei,
);

// Sync & queries
pub type PFN_glFenceSync =
    unsafe extern "system" fn(condition: GLenum, flags: GLbitfield) -> GLsync;
pub type PFN_glDeleteSync = unsafe extern "system" fn(sync: GLsync);
pub type PFN_glClientWaitSync =
    unsafe extern "system" fn(sync: GLsync, flags: GLbitfield, timeout: GLuint64) -> GLenum;
pub type PFN_glWaitSync =
    unsafe extern "system" fn(sync: GLsync, flags: GLbitfield, timeout: GLuint64);

pub type PFN_glGenQueries = unsafe extern "system" fn(n: GLsizei, ids: *mut GLuint);
pub type PFN_glDeleteQueries = unsafe extern "system" fn(n: GLsizei, ids: *const GLuint);
pub type PFN_glBeginQuery = unsafe extern "system" fn(target: GLenum, id: GLuint);
pub type PFN_glEndQuery = unsafe extern "system" fn(target: GLenum);
pub type PFN_glGetQueryObjectuiv =
    unsafe extern "system" fn(id: GLuint, pname: GLenum, params: *mut GLuint);
pub type PFN_glGetQueryObjectui64v =
    unsafe extern "system" fn(id: GLuint, pname: GLenum, params: *mut GLuint64);
pub type PFN_glQueryCounter = unsafe extern "system" fn(id: GLuint, target: GLenum);

// Debug output (GL 4.3 / KHR_debug)
pub type PFN_glDebugMessageCallback =
    unsafe extern "system" fn(callback: GLDEBUGPROC, user_param: *const c_void);
pub type PFN_glDebugMessageControl = unsafe extern "system" fn(
    source: GLenum,
    gltype: GLenum,
    severity: GLenum,
    count: GLsizei,
    ids: *const GLuint,
    enabled: GLboolean,
);