4 version = glbind_lazy_load
;
6 // show loaded functions
7 //version = glbind_debug;
10 static if (__traits(compiles
, () { import arsd
.simpledisplay
; })) {
11 public import arsd
.simpledisplay
;
13 public import simpledisplay
;
17 // ////////////////////////////////////////////////////////////////////////// //
18 extern(C
) nothrow @nogc {
21 alias GLintptr
= ptrdiff_t
;
24 alias GLcharARB
= byte;
25 alias GLushort
= ushort;
26 alias GLint64EXT
= long;
27 alias GLshort
= short;
28 alias GLuint64
= ulong;
29 alias GLhalfARB
= ushort;
30 alias GLubyte
= ubyte;
31 alias GLdouble
= double;
32 alias GLhandleARB
= uint;
35 alias GLeglImageOES
= void*;
36 alias GLintptrARB
= ptrdiff_t
;
37 alias GLsizeiptr
= ptrdiff_t
;
39 alias GLboolean
= ubyte;
40 alias GLbitfield
= uint;
41 alias GLsizeiptrARB
= ptrdiff_t
;
42 alias GLfloat
= float;
43 alias GLuint64EXT
= ulong;
44 alias GLclampf
= float;
46 alias GLclampd
= double;
48 alias GLvdpauSurfaceNV
= ptrdiff_t
;
50 alias GLhalf
= ushort;
52 alias GLhalfNV
= ushort;
53 struct ___GLsync
; alias __GLsync
= ___GLsync
*;
54 alias GLsync
= __GLsync
*;
55 struct __cl_context
; alias _cl_context
= __cl_context
*;
56 struct __cl_event
; alias _cl_event
= __cl_event
*;
59 enum uint GL_RGBA8
= 0x8058;
60 enum uint GL_FRAGMENT_SHADER
= 0x8B30;
61 enum uint GL_COMPILE_STATUS
= 0x8B81;
62 enum uint GL_INFO_LOG_LENGTH
= 0x8B84;
63 enum uint GL_FRAMEBUFFER_COMPLETE_EXT
= 0x8CD5;
64 enum uint GL_FRAMEBUFFER_EXT
= 0x8D40;
65 enum uint GL_COLOR_ATTACHMENT0_EXT
= 0x8CE0;
66 enum uint GL_RENDERBUFFER_EXT
= 0x8D41;
67 enum uint GL_DEPTH_COMPONENT16
= 0x81A5;
68 enum uint GL_DEPTH_COMPONENT24
= 0x81A6;
69 enum uint GL_DEPTH_COMPONENT32
= 0x81A7;
70 enum uint GL_DEPTH_ATTACHMENT_EXT
= 0x8D00;
71 enum uint GL_CLAMP_TO_BORDER
= 0x812D;
72 enum uint GL_TEXTURE0
= 0x84C0;
73 enum uint GL_TEXTURE1
= 0x84C1;
74 enum uint GL_TEXTURE2
= 0x84C2;
75 enum uint GL_TEXTURE3
= 0x84C3;
76 enum uint GL_TEXTURE4
= 0x84C4;
77 enum uint GL_TEXTURE5
= 0x84C5;
78 enum uint GL_TEXTURE6
= 0x84C6;
79 enum uint GL_TEXTURE7
= 0x84C7;
80 enum uint GL_TEXTURE8
= 0x84C8;
81 enum uint GL_TEXTURE9
= 0x84C9;
82 enum uint GL_TEXTURE10
= 0x84CA;
83 enum uint GL_TEXTURE11
= 0x84CB;
84 enum uint GL_TEXTURE12
= 0x84CC;
85 enum uint GL_TEXTURE13
= 0x84CD;
86 enum uint GL_TEXTURE14
= 0x84CE;
87 enum uint GL_TEXTURE15
= 0x84CF;
88 enum uint GL_TEXTURE16
= 0x84D0;
89 enum uint GL_TEXTURE17
= 0x84D1;
90 enum uint GL_TEXTURE18
= 0x84D2;
91 enum uint GL_TEXTURE19
= 0x84D3;
92 enum uint GL_TEXTURE20
= 0x84D4;
93 enum uint GL_TEXTURE21
= 0x84D5;
94 enum uint GL_TEXTURE22
= 0x84D6;
95 enum uint GL_TEXTURE23
= 0x84D7;
96 enum uint GL_TEXTURE24
= 0x84D8;
97 enum uint GL_TEXTURE25
= 0x84D9;
98 enum uint GL_TEXTURE26
= 0x84DA;
99 enum uint GL_TEXTURE27
= 0x84DB;
100 enum uint GL_TEXTURE28
= 0x84DC;
101 enum uint GL_TEXTURE29
= 0x84DD;
102 enum uint GL_TEXTURE30
= 0x84DE;
103 enum uint GL_TEXTURE31
= 0x84DF;
104 enum uint GL_ACTIVE_TEXTURE
= 0x84E0;
105 enum uint GL_COMPILE
= 0x1300;
106 enum uint GL_COMPILE_AND_EXECUTE
= 0x1301;
107 enum uint GL_TEXTURE_CUBE_MAP
= 0x8513;
108 enum uint GL_TEXTURE_WRAP_R
= 0x8072;
109 enum uint GL_TEXTURE_CUBE_MAP_POSITIVE_X
= 0x8515;
110 enum uint GL_TEXTURE_CUBE_MAP_NEGATIVE_X
= 0x8516;
111 enum uint GL_TEXTURE_CUBE_MAP_POSITIVE_Y
= 0x8517;
112 enum uint GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
= 0x8518;
113 enum uint GL_TEXTURE_CUBE_MAP_POSITIVE_Z
= 0x8519;
114 enum uint GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
= 0x851A;
115 enum uint GL_TEXTURE_BORDER_COLOR
= 0x1004;
116 enum uint GL_RGBA16F
= 0x881A;
117 enum uint GL_FLOAT
= 0x1406;
118 enum uint GL_DOUBLE
= 0x140A;
120 alias glbfn_glTexParameterf
= void function (GLenum
, GLenum
, GLfloat
);
121 alias glbfn_glTexParameterfv
= void function (GLenum
, GLenum
, const(GLfloat
)*);
122 alias glbfn_glTexParameteri
= void function (GLenum
, GLenum
, GLint
);
123 alias glbfn_glTexParameteriv
= void function (GLenum
, GLenum
, const(GLint
)*);
125 alias glbfn_glCreateShader
= GLuint
function (GLenum
);
126 alias glbfn_glShaderSource
= void function (GLuint
, GLsizei
, const(GLchar
*)*, const(GLint
)*);
127 alias glbfn_glCompileShader
= void function (GLuint
);
128 alias glbfn_glCreateProgram
= GLuint
function ();
129 alias glbfn_glAttachShader
= void function (GLuint
, GLuint
);
130 alias glbfn_glLinkProgram
= void function (GLuint
);
131 alias glbfn_glUseProgram
= void function (GLuint
);
132 alias glbfn_glGetShaderiv
= void function (GLuint
, GLenum
, GLint
*);
133 alias glbfn_glGetShaderInfoLog
= void function (GLuint
, GLsizei
, GLsizei
*, GLchar
*);
135 alias glbfn_glGetUniformLocation
= GLint
function (GLuint
, const(GLchar
)*);
137 alias glbfn_glUniform1f
= void function (GLint
, GLfloat
);
138 alias glbfn_glUniform2f
= void function (GLint
, GLfloat
, GLfloat
);
139 alias glbfn_glUniform3f
= void function (GLint
, GLfloat
, GLfloat
, GLfloat
);
140 alias glbfn_glUniform4f
= void function (GLint
, GLfloat
, GLfloat
, GLfloat
, GLfloat
);
141 alias glbfn_glUniform1i
= void function (GLint
, GLint
);
142 alias glbfn_glUniform2i
= void function (GLint
, GLint
, GLint
);
143 alias glbfn_glUniform3i
= void function (GLint
, GLint
, GLint
, GLint
);
144 alias glbfn_glUniform4i
= void function (GLint
, GLint
, GLint
, GLint
, GLint
);
145 alias glbfn_glUniform1fv
= void function (GLint
, GLsizei
, const(GLfloat
)*);
146 alias glbfn_glUniform2fv
= void function (GLint
, GLsizei
, const(GLfloat
)*);
147 alias glbfn_glUniform3fv
= void function (GLint
, GLsizei
, const(GLfloat
)*);
148 alias glbfn_glUniform4fv
= void function (GLint
, GLsizei
, const(GLfloat
)*);
149 alias glbfn_glUniform1iv
= void function (GLint
, GLsizei
, const(GLint
)*);
150 alias glbfn_glUniform2iv
= void function (GLint
, GLsizei
, const(GLint
)*);
151 alias glbfn_glUniform3iv
= void function (GLint
, GLsizei
, const(GLint
)*);
152 alias glbfn_glUniform4iv
= void function (GLint
, GLsizei
, const(GLint
)*);
153 alias glbfn_glUniformMatrix2fv
= void function (GLint
, GLsizei
, GLboolean
, const(GLfloat
)*);
154 alias glbfn_glUniformMatrix3fv
= void function (GLint
, GLsizei
, GLboolean
, const(GLfloat
)*);
155 alias glbfn_glUniformMatrix4fv
= void function (GLint
, GLsizei
, GLboolean
, const(GLfloat
)*);
157 alias glbfn_glGenFramebuffersEXT
= void function (GLsizei
, GLuint
*);
158 alias glbfn_glBindFramebufferEXT
= void function (GLenum
, GLuint
);
159 alias glbfn_glFramebufferTexture2DEXT
= void function (GLenum
, GLenum
, GLenum
, GLuint
, GLint
);
160 alias glbfn_glGenRenderbuffersEXT
= void function (GLsizei
, GLuint
*);
161 alias glbfn_glRenderbufferStorageEXT
= void function (GLenum
, GLenum
, GLsizei
, GLsizei
);
162 alias glbfn_glFramebufferRenderbufferEXT
= void function (GLenum
, GLenum
, GLenum
, GLuint
);
163 alias glbfn_glCheckFramebufferStatusEXT
= GLenum
function (GLenum
);
164 alias glbfn_glBindRenderbufferEXT
= void function (GLenum
, GLuint
);
166 alias glbfn_glActiveTexture
= void function (GLenum
);
168 alias glbfn_glGenLists
= GLuint
function (GLsizei
);
169 alias glbfn_glNewList
= void function (GLuint
, GLenum
);
170 alias glbfn_glEndList
= void function ();
171 alias glbfn_glCallList
= void function (GLuint
);
172 alias glbfn_glCallLists
= void function (GLsizei
, GLenum
, const(void)*);
173 alias glbfn_glDeleteLists
= void function (GLuint
, GLsizei
);
175 enum uint GL_VERSION
= 0x1F02;
176 enum uint GL_EXTENSIONS
= 0x1F03;
177 enum uint GL_SHADING_LANGUAGE_VERSION
= 0x8B8C;
179 alias glbfn_glGetString
= const(char*) function (GLenum
);
180 alias glbfn_glGetStringi
= const(char)* function (GLenum
, GLuint
);
182 enum uint GL_MAJOR_VERSION
= 0x821B;
183 enum uint GL_MINOR_VERSION
= 0x821C;
184 enum uint GL_NUM_EXTENSIONS
= 0x821D;
185 enum uint GL_NUM_SHADING_LANGUAGE_VERSIONS
= 0x82E9;
187 alias glbfn_glGetIntegerv
= void function (GLenum
, GLint
*);
191 // ////////////////////////////////////////////////////////////////////////// //
192 version(glbind_lazy_load
) {
193 private string
glbindCreateInternalVars () {
195 foreach (name
; __traits(allMembers
, mixin(__MODULE__
))) {
196 static if (name
.length
> 6 && name
[0..6] == "glbfn_") {
197 //pragma(msg, mixin(name));
199 //pragma(msg, ReturnType!(mixin(name)));
200 //pragma(msg, Parameters!(mixin(name)));
203 foreach (immutable idx
, immutable ptype
; Parameters
!(mixin(name
))) {
204 import std
.conv
: to
;
205 pars
~= ", "~ptype
.stringof
~" a"~to
!string(idx
);
206 call ~= "a"~to
!string(idx
)~",";
208 if (pars
.length
) pars
= pars
[2..$];
209 res
~= "__gshared "~name
~" "~name
[6..$]~" = function "~
210 ReturnType
!(mixin(name
)).stringof
~" "~
211 /*Parameters!(mixin(name)).stringof*/"("~pars
~") nothrow{\n"~
213 " "~name
[6..$]~" = cast("~name
~")glGetProcAddress(`"~name
[6..$]~"`);\n"~
214 " if ("~name
[6..$]~" is null) assert(0, `OpenGL function '"~name
[6..$]~"' not found!`);\n"~
215 " version(glbind_debug) { import core.stdc.stdio; fprintf(stderr, \"GLBIND: '"~name
[6..$]~"'\\n\"); }\n"~
216 " "~(is(ReturnType
!(mixin(name
)) == void) ?
"" : "return ")~name
[6..$]~"("~call~");\n"~
217 //" assert(0, `"~name[6..$]~"`);\n"~
224 private string
glbindCreateInternalVars () {
226 foreach (name
; __traits(allMembers
, mixin(__MODULE__
))) {
227 static if (name
.length
> 6 && name
[0..6] == "glbfn_") {
230 res
~= "__gshared "~name
~" "~name
[6..$]~";\n";
236 mixin(glbindCreateInternalVars());
239 public void glbindLoadFunctions () {
240 version(glbind_lazy_load
) {} else {
241 foreach (name
; __traits(allMembers
, mixin(__MODULE__
))) {
242 static if (name
.length
> 6 && name
[0..6] == "glbfn_") {
245 mixin(name
[6..$]~" = cast("~name
~")glGetProcAddress(`"~name
[6..$]~"`);");
246 mixin("if ("~name
[6..$]~" is null) assert(0, `OpenGL function '"~name
[6..$]~"' not found!`);");
253 //void main () { glbindLoadFunctions(); }