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.gl15;
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.gl14;
15 
16 enum : uint {
17     GL_BUFFER_SIZE                    = 0x8764,
18     GL_BUFFER_USAGE                   = 0x8765,
19     GL_QUERY_COUNTER_BITS             = 0x8864,
20     GL_CURRENT_QUERY                  = 0x8865,
21     GL_QUERY_RESULT                   = 0x8866,
22     GL_QUERY_RESULT_AVAILABLE         = 0x8867,
23     GL_ARRAY_BUFFER                   = 0x8892,
24     GL_ELEMENT_ARRAY_BUFFER           = 0x8893,
25     GL_ARRAY_BUFFER_BINDING           = 0x8894,
26     GL_ELEMENT_ARRAY_BUFFER_BINDING   = 0x8895,
27     GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F,
28     GL_READ_ONLY                      = 0x88B8,
29     GL_WRITE_ONLY                     = 0x88B9,
30     GL_READ_WRITE                     = 0x88BA,
31     GL_BUFFER_ACCESS                  = 0x88BB,
32     GL_BUFFER_MAPPED                  = 0x88BC,
33     GL_BUFFER_MAP_POINTER             = 0x88BD,
34     GL_STREAM_DRAW                    = 0x88E0,
35     GL_STREAM_READ                    = 0x88E1,
36     GL_STREAM_COPY                    = 0x88E2,
37     GL_STATIC_DRAW                    = 0x88E4,
38     GL_STATIC_READ                    = 0x88E5,
39     GL_STATIC_COPY                    = 0x88E6,
40     GL_DYNAMIC_DRAW                   = 0x88E8,
41     GL_DYNAMIC_READ                   = 0x88E9,
42     GL_DYNAMIC_COPY                   = 0x88EA,
43     GL_SAMPLES_PASSED                 = 0x8914,
44     GL_SRC1_ALPHA                     = 0x8589,
45 }
46 
47 extern(System) @nogc nothrow {
48     alias pglGenQueries = void function(GLsizei,GLuint*);
49     alias pglDeleteQueries = void function(GLsizei,const(GLuint)*);
50     alias pglIsQuery = GLboolean function(GLuint);
51     alias pglBeginQuery = void function(GLenum,GLuint);
52     alias pglEndQuery = void function(GLenum);
53     alias pglGetQueryiv = void function(GLenum,GLenum,GLint*);
54     alias pglGetQueryObjectiv = void function(GLuint,GLenum,GLint*);
55     alias pglGetQueryObjectuiv = void function(GLuint,GLenum,GLuint*);
56     alias pglBindBuffer = void function(GLenum,GLuint);
57     alias pglDeleteBuffers = void function(GLsizei,const(GLuint)*);
58     alias pglGenBuffers = void function(GLsizei,GLuint*);
59     alias pglIsBuffer = GLboolean function(GLuint);
60     alias pglBufferData = void function(GLenum,GLsizeiptr,const(GLvoid)*,GLenum);
61     alias pglBufferSubData = void function(GLenum,GLintptr,GLsizeiptr,const(GLvoid)*);
62     alias pglGetBufferSubData = void function(GLenum,GLintptr,GLsizeiptr,GLvoid*);
63     alias pglMapBuffer = GLvoid* function(GLenum,GLenum);
64     alias pglUnmapBuffer = GLboolean function(GLenum);
65     alias pglGetBufferParameteriv = void function(GLenum,GLenum,GLint*);
66     alias pglGetBufferPointerv = void function(GLenum,GLenum,GLvoid*);
67 }
68 
69 __gshared {
70     pglGenQueries glGenQueries;
71     pglDeleteQueries glDeleteQueries;
72     pglIsQuery glIsQuery;
73     pglBeginQuery glBeginQuery;
74     pglEndQuery glEndQuery;
75     pglGetQueryiv glGetQueryiv;
76     pglGetQueryObjectiv glGetQueryObjectiv;
77     pglGetQueryObjectuiv glGetQueryObjectuiv;
78     pglBindBuffer glBindBuffer;
79     pglDeleteBuffers glDeleteBuffers;
80     pglGenBuffers glGenBuffers;
81     pglIsBuffer glIsBuffer;
82     pglBufferData glBufferData;
83     pglBufferSubData glBufferSubData;
84     pglGetBufferSubData glGetBufferSubData;
85     pglMapBuffer glMapBuffer;
86     pglUnmapBuffer glUnmapBuffer;
87     pglGetBufferParameteriv glGetBufferParameteriv;
88     pglGetBufferPointerv glGetBufferPointerv;
89 }
90 
91 package(bindbc.opengl) @nogc nothrow
92 bool loadGL15(SharedLib lib, GLSupport contextVersion)
93 {
94     if(contextVersion > GLSupport.gl14) {
95         lib.bindGLSymbol(cast(void**)&glGenQueries, "glGenQueries");
96         lib.bindGLSymbol(cast(void**)&glDeleteQueries, "glDeleteQueries");
97         lib.bindGLSymbol(cast(void**)&glIsQuery, "glIsQuery");
98         lib.bindGLSymbol(cast(void**)&glBeginQuery, "glBeginQuery");
99         lib.bindGLSymbol(cast(void**)&glEndQuery, "glEndQuery");
100         lib.bindGLSymbol(cast(void**)&glGetQueryiv, "glGetQueryiv");
101         lib.bindGLSymbol(cast(void**)&glGetQueryObjectiv, "glGetQueryObjectiv");
102         lib.bindGLSymbol(cast(void**)&glGetQueryObjectuiv, "glGetQueryObjectuiv");
103         lib.bindGLSymbol(cast(void**)&glBindBuffer, "glBindBuffer");
104         lib.bindGLSymbol(cast(void**)&glDeleteBuffers, "glDeleteBuffers");
105         lib.bindGLSymbol(cast(void**)&glGenBuffers, "glGenBuffers");
106         lib.bindGLSymbol(cast(void**)&glIsBuffer, "glIsBuffer");
107         lib.bindGLSymbol(cast(void**)&glBufferData, "glBufferData");
108         lib.bindGLSymbol(cast(void**)&glBufferSubData, "glBufferSubData");
109         lib.bindGLSymbol(cast(void**)&glGetBufferSubData, "glGetBufferSubData");
110         lib.bindGLSymbol(cast(void**)&glMapBuffer, "glMapBuffer");
111         lib.bindGLSymbol(cast(void**)&glUnmapBuffer, "glUnmapBuffer");
112         lib.bindGLSymbol(cast(void**)&glGetBufferParameteriv, "glGetBufferParameteriv");
113         lib.bindGLSymbol(cast(void**)&glGetBufferPointerv, "glGetBufferPointerv");
114         if(errorCountGL() == 0) return true;
115     }
116     return false;
117 }