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.gl12;
8 
9 import bindbc.loader : SharedLib;
10 import bindbc.opengl.config,
11        bindbc.opengl.context;
12 import bindbc.opengl.bind.types;
13 
14 public import bindbc.opengl.bind.gl11;
15 version(GL_AllowDeprecated)
16     public import bindbc.opengl.bind.dep.dep12;
17 
18 enum : uint {
19     GL_UNSIGNED_BYTE_3_3_2            = 0x8032,
20     GL_UNSIGNED_SHORT_4_4_4_4         = 0x8033,
21     GL_UNSIGNED_SHORT_5_5_5_1         = 0x8034,
22     GL_UNSIGNED_INT_8_8_8_8           = 0x8035,
23     GL_UNSIGNED_INT_10_10_10_2        = 0x8036,
24     GL_TEXTURE_BINDING_3D             = 0x806A,
25     GL_PACK_SKIP_IMAGES               = 0x806B,
26     GL_PACK_IMAGE_HEIGHT              = 0x806C,
27     GL_UNPACK_SKIP_IMAGES             = 0x806D,
28     GL_UNPACK_IMAGE_HEIGHT            = 0x806E,
29     GL_TEXTURE_3D                     = 0x806F,
30     GL_PROXY_TEXTURE_3D               = 0x8070,
31     GL_TEXTURE_DEPTH                  = 0x8071,
32     GL_TEXTURE_WRAP_R                 = 0x8072,
33     GL_MAX_3D_TEXTURE_SIZE            = 0x8073,
34     GL_UNSIGNED_BYTE_2_3_3_REV        = 0x8362,
35     GL_UNSIGNED_SHORT_5_6_5           = 0x8363,
36     GL_UNSIGNED_SHORT_5_6_5_REV       = 0x8364,
37     GL_UNSIGNED_SHORT_4_4_4_4_REV     = 0x8365,
38     GL_UNSIGNED_SHORT_1_5_5_5_REV     = 0x8366,
39     GL_UNSIGNED_INT_8_8_8_8_REV       = 0x8367,
40     GL_UNSIGNED_INT_2_10_10_10_REV    = 0x8368,
41     GL_BGR                            = 0x80E0,
42     GL_BGRA                           = 0x80E1,
43     GL_MAX_ELEMENTS_VERTICES          = 0x80E8,
44     GL_MAX_ELEMENTS_INDICES           = 0x80E9,
45     GL_CLAMP_TO_EDGE                  = 0x812F,
46     GL_TEXTURE_MIN_LOD                = 0x813A,
47     GL_TEXTURE_MAX_LOD                = 0x813B,
48     GL_TEXTURE_BASE_LEVEL             = 0x813C,
49     GL_TEXTURE_MAX_LEVEL              = 0x813D,
50     GL_SMOOTH_POINT_SIZE_RANGE        = 0x0B12,
51     GL_SMOOTH_POINT_SIZE_GRANULARITY  = 0x0B13,
52     GL_SMOOTH_LINE_WIDTH_RANGE        = 0x0B22,
53     GL_SMOOTH_LINE_WIDTH_GRANULARITY  = 0x0B23,
54     GL_ALIASED_LINE_WIDTH_RANGE       = 0x846E,
55 }
56 
57 extern(System) @nogc nothrow {
58     alias pglDrawRangeElements = void function(GLenum,GLuint,GLuint,GLsizei,GLenum,const(GLvoid)*);
59     alias pglTexImage3D = void function(GLenum,GLint,GLint,GLsizei,GLsizei,GLsizei,GLint,GLenum,GLenum,const(GLvoid)*);
60     alias pglTexSubImage3D = void function(GLenum,GLint,GLint,GLint,GLint,GLsizei,GLsizei,GLsizei,GLenum,GLenum,const(GLvoid)*);
61     alias pglCopyTexSubImage3D = void function(GLenum,GLint,GLint,GLint,GLint,GLint,GLint,GLsizei,GLsizei);
62 }
63 
64 __gshared {
65     pglDrawRangeElements glDrawRangeElements;
66     pglTexImage3D glTexImage3D;
67     pglTexSubImage3D glTexSubImage3D;
68     pglCopyTexSubImage3D glCopyTexSubImage3D;
69 }
70 
71 package(bindbc.opengl) @nogc nothrow
72 bool loadGL12(SharedLib lib, GLSupport contextVersion)
73 {
74     if(contextVersion > GLSupport.gl11) {
75         lib.bindGLSymbol(cast(void**)&glDrawRangeElements, "glDrawRangeElements");
76         lib.bindGLSymbol(cast(void**)&glTexImage3D, "glTexImage3D");
77         lib.bindGLSymbol(cast(void**)&glTexSubImage3D, "glTexSubImage3D");
78         lib.bindGLSymbol(cast(void**)&glCopyTexSubImage3D, "glCopyTexSubImage3D");
79 
80         if(errorCountGL() == 0) {
81             version(GL_AllowDeprecated) return loadDeprecatedGL12(lib);
82             else return true;
83         }
84     }
85     return false;
86 }