GLUtil_GL.cs 25 KB
Newer Older
pcy's avatar
initial  
pcy committed
1
2
3
using System;
using System.Collections.Generic;
using System.Linq;
pcy's avatar
pcy committed
4
using System.Runtime.InteropServices;
pcy's avatar
pcy committed
5
using System.Text;
pcy's avatar
initial  
pcy committed
6
7
8
9

using GLenum     = System.UInt32;
using GLboolean  = System.Byte  ;
using GLbitfield = System.UInt32;
10
//using GLvoid     = System.Void  ;
pcy's avatar
initial  
pcy committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using GLbyte     = System.SByte ;
using GLshort    = System.Int16 ;
using GLint      = System.Int32 ;
using GLubyte    = System.Byte  ;
using GLushort   = System.UInt16;
using GLuint     = System.UInt32;
using GLsizei    = System.Int32 ;
using GLfloat    = System.Single;
using GLclampf   = System.Single;
using GLdouble   = System.Double;
using GLclampd   = System.Double;
using GLchar     = System.SByte ;

namespace PoroCYon.FNAGLSL {
	public static unsafe partial class GL {
		static void InitProcs() {
pcy's avatar
pcy committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
			_GetError      = GetProcAddress<GetError_T>("GetError");
			_CreateProgram = GetProcAddress<CreateProgram_T>("CreateProgram");
			_CreateShader  = GetProcAddress<CreateShader_T>("CreateShader");
			_ShaderSource  = GetProcAddress<ShaderSource_T>("ShaderSource");
			_CompileShader = GetProcAddress<CompileShader_T>("CompileShader");
			_GetShaderiv   = GetProcAddress<GetShaderiv_T>("GetShaderiv");
			_GetShaderInfoLog = GetProcAddress<GetShaderInfoLog_T>("GetShaderInfoLog");
			_AttachShader  = GetProcAddress<AttachShader_T>("AttachShader");
			_LinkProgram   = GetProcAddress<LinkProgram_T>("LinkProgram");
			_GetProgramiv  = GetProcAddress<GetProgramiv_T>("GetProgramiv");
			_GetProgramInfoLog = GetProcAddress<GetProgramInfoLog_T>("GetProgramInfoLog");
			_DeleteShader  = GetProcAddress<DeleteShader_T>("DeleteShader");
			_DeleteProgram = GetProcAddress<DeleteProgram_T>("DeleteProgram");
			_UseProgram    = GetProcAddress<UseProgram_T>("UseProgram");
			_GetIntegerv   = GetProcAddress<GetIntegerv_T>("GetIntegerv");
pcy's avatar
pcy committed
42
43
44
45
46
47
48
			_GetActiveAttrib    = GetProcAddress<GetActiveAttrib_T>("GetActiveAttrib");
			_GetAttribLocation  = GetProcAddress<GetAttribLocation_T>("GetAttribLocation");
			_GetUniformIndices  = GetProcAddress<GetUniformIndices_T>("GetUniformIndices");
			_GetUniformLocation = GetProcAddress<GetUniformLocation_T>("GetUniformLocation");
			_GetActiveUniformName = GetProcAddress<GetActiveUniformName_T>("GetActiveUniformName");
			_GetActiveUniformsiv  = GetProcAddress<GetActiveUniformsiv_T>("GetActiveUniformsiv");
			_GetActiveUniform     = GetProcAddress<GetActiveUniform_T>("GetActiveUniform");
pcy's avatar
pcy committed
49

pcy's avatar
pcy committed
50
51
52
			_ActiveTexture = GetProcAddress<ActiveTexture_T>("ActiveTexture");
			_BindTexture = GetProcAddress<BindTexture_T>("BindTexture");

pcy's avatar
pcy committed
53
54
			_Enable = GetProcAddress<Enable_T>("Enable");
			_Disable = GetProcAddress<Disable_T>("Disable");
pcy's avatar
lol    
pcy committed
55
56
			_DebugMessageCallback = GetProcAddress<DebugMessageCallback_T>("DebugMessageCallback", false);
			_DebugMessageControl = GetProcAddress<DebugMessageControl_T>("DebugMessageControl", false);
pcy's avatar
pcy committed
57

pcy's avatar
pcy committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
			_Uniform1fv = GetProcAddress<Uniform1fv_T>("Uniform1fv");
			_Uniform2fv = GetProcAddress<Uniform2fv_T>("Uniform2fv");
			_Uniform3fv = GetProcAddress<Uniform3fv_T>("Uniform3fv");
			_Uniform4fv = GetProcAddress<Uniform4fv_T>("Uniform4fv");
			_Uniform1iv = GetProcAddress<Uniform1iv_T>("Uniform1iv");
			_Uniform2iv = GetProcAddress<Uniform2iv_T>("Uniform2iv");
			_Uniform3iv = GetProcAddress<Uniform3iv_T>("Uniform3iv");
			_Uniform4iv = GetProcAddress<Uniform4iv_T>("Uniform4iv");
			_Uniform1uiv = GetProcAddress<Uniform1uiv_T>("Uniform1uiv");
			_Uniform2uiv = GetProcAddress<Uniform2uiv_T>("Uniform2uiv");
			_Uniform3uiv = GetProcAddress<Uniform3uiv_T>("Uniform3uiv");
			_Uniform4uiv = GetProcAddress<Uniform4uiv_T>("Uniform4uiv");

			_UniformMatrix2fv = GetProcAddress<UniformMatrix2fv_T>("UniformMatrix2fv");
			_UniformMatrix3fv = GetProcAddress<UniformMatrix3fv_T>("UniformMatrix3fv");
			_UniformMatrix4fv = GetProcAddress<UniformMatrix4fv_T>("UniformMatrix4fv");
			_UniformMatrix2x3fv = GetProcAddress<UniformMatrix2x3fv_T>("UniformMatrix2x3fv");
			_UniformMatrix3x2fv = GetProcAddress<UniformMatrix3x2fv_T>("UniformMatrix3x2fv");
			_UniformMatrix2x4fv = GetProcAddress<UniformMatrix2x4fv_T>("UniformMatrix2x4fv");
			_UniformMatrix4x2fv = GetProcAddress<UniformMatrix4x2fv_T>("UniformMatrix4x2fv");
			_UniformMatrix3x4fv = GetProcAddress<UniformMatrix3x4fv_T>("UniformMatrix3x4fv");
			_UniformMatrix4x3fv = GetProcAddress<UniformMatrix4x3fv_T>("UniformMatrix4x3fv");
pcy's avatar
pcy committed
80
81
82
83
84
85
86
87
88
89
90
91
92

			_Uniform1f = GetProcAddress<Uniform1f_T>("Uniform1f");
			_Uniform2f = GetProcAddress<Uniform2f_T>("Uniform2f");
			_Uniform3f = GetProcAddress<Uniform3f_T>("Uniform3f");
			_Uniform4f = GetProcAddress<Uniform4f_T>("Uniform4f");
			_Uniform1i = GetProcAddress<Uniform1i_T>("Uniform1i");
			_Uniform2i = GetProcAddress<Uniform2i_T>("Uniform2i");
			_Uniform3i = GetProcAddress<Uniform3i_T>("Uniform3i");
			_Uniform4i = GetProcAddress<Uniform4i_T>("Uniform4i");
			_Uniform1ui = GetProcAddress<Uniform1ui_T>("Uniform1ui");
			_Uniform2ui = GetProcAddress<Uniform2ui_T>("Uniform2ui");
			_Uniform3ui = GetProcAddress<Uniform3ui_T>("Uniform3ui");
			_Uniform4ui = GetProcAddress<Uniform4ui_T>("Uniform4ui");
pcy's avatar
initial  
pcy committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
		}
		static void DeinitProcs() {
			_GetError      = null;
			_CreateProgram = null;
			_CreateShader  = null;
			_ShaderSource  = null;
			_CompileShader = null;
			_GetShaderiv   = null;
			_GetShaderInfoLog = null;
			_AttachShader  = null;
			_LinkProgram   = null;
			_GetProgramiv  = null;
			_GetProgramInfoLog = null;
			_DeleteShader  = null;
			_DeleteProgram = null;
108
109
			_UseProgram    = null;
			_GetIntegerv   = null;
pcy's avatar
pcy committed
110
111
112
113
114
115
116
			_GetActiveAttrib    = null;
			_GetAttribLocation  = null;
			_GetUniformIndices  = null;
			_GetUniformLocation = null;
			_GetActiveUniformName = null;
			_GetActiveUniformsiv  = null;
			_GetActiveUniform     = null;
pcy's avatar
pcy committed
117

pcy's avatar
pcy committed
118
119
120
121
122
			_ActiveTexture = null;
			_BindTexture = null;

			_Enable = null;
			_Disable = null;
pcy's avatar
lol    
pcy committed
123
124
			_DebugMessageCallback = null;
			_DebugMessageControl = null;
pcy's avatar
pcy committed
125

pcy's avatar
pcy committed
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
			_Uniform1fv = null;
			_Uniform2fv = null;
			_Uniform3fv = null;
			_Uniform4fv = null;
			_Uniform1iv = null;
			_Uniform2iv = null;
			_Uniform3iv = null;
			_Uniform4iv = null;
			_Uniform1uiv = null;
			_Uniform2uiv = null;
			_Uniform3uiv = null;
			_Uniform4uiv = null;

			_UniformMatrix2fv = null;
			_UniformMatrix3fv = null;
			_UniformMatrix4fv = null;
			_UniformMatrix2x3fv = null;
			_UniformMatrix3x2fv = null;
			_UniformMatrix2x4fv = null;
			_UniformMatrix4x2fv = null;
			_UniformMatrix3x4fv = null;
			_UniformMatrix4x3fv = null;
pcy's avatar
pcy committed
148
149
150
151
152
153
154
155
156
157
158
159
160

			_Uniform1f = null;
			_Uniform2f = null;
			_Uniform3f = null;
			_Uniform4f = null;
			_Uniform1i = null;
			_Uniform2i = null;
			_Uniform3i = null;
			_Uniform4i = null;
			_Uniform1ui = null;
			_Uniform2ui = null;
			_Uniform3ui = null;
			_Uniform4ui = null;
pcy's avatar
initial  
pcy committed
161
162
		}

pcy's avatar
pcy committed
163
164
		delegate GLenum GetError_T();
		static GetError_T _GetError;
pcy's avatar
initial  
pcy committed
165
166
		public static GLError GetError() => (GLError)_GetError();

pcy's avatar
pcy committed
167
168
		delegate GLuint CreateProgram_T();
		static CreateProgram_T _CreateProgram;
pcy's avatar
initial  
pcy committed
169
170
		public static GLuint CreateProgram() => _CreateProgram();

pcy's avatar
pcy committed
171
172
		delegate GLuint CreateShader_T(GLenum shtyp);
		static CreateShader_T _CreateShader;
pcy's avatar
initial  
pcy committed
173
174
175
		public static GLuint CreateShader(GLSLPurpose shtyp)
			=> _CreateShader((GLenum)shtyp);

pcy's avatar
pcy committed
176
177
178
		delegate void ShaderSource_T(GLuint sh, GLsizei count,
				GLchar** str, GLint* len);
		static ShaderSource_T _ShaderSource;
pcy's avatar
pcy committed
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
		public static void ShaderSource(GLuint sh, string[] srcs) {
			int count = srcs.Length;

			// marshal the string array...
			byte[][] strs = new byte[count][];
			GLint[] lens = new GLint[count];

			// convert all the strings to utf8
			int totallen = 0;
			for (int i = 0; i < count; ++i) {
				strs[i] = GetNullTermUTF8(srcs[i]);
				totallen += (lens[i] = strs[i].Length);
			}

			// rearrange pointer crap so that GL can use it
			byte[] bytesbytes = new byte[totallen];
			GLchar*[] ptrs = new GLchar*[count];
			fixed (byte* bbp = bytesbytes) {
				int totalidx = 0;
				for (int i = 0; i < count; ++i) {
					Array.Copy(strs[i], 0, bytesbytes, totalidx, lens[i]);
					ptrs[i] = (GLchar*)&bbp[totalidx];
					totalidx += lens[i];
				}

				// now we can actually call the function
				fixed (GLchar** strp = ptrs) {
					fixed (GLint* lenp = lens) {
						_ShaderSource(sh, count, strp, lenp);
					}
				}
			}
		}
		readonly static string[] strarr = new string[1];
		public static void ShaderSource(GLuint sh, string src) {
			strarr[0] = src;
			ShaderSource(sh, strarr);
pcy's avatar
initial  
pcy committed
216
217
		}

pcy's avatar
pcy committed
218
219
		delegate void CompileShader_T(GLuint sh);
		static CompileShader_T _CompileShader;
pcy's avatar
initial  
pcy committed
220
221
		public static void CompileShader(GLuint sh) { _CompileShader(sh); }

pcy's avatar
pcy committed
222
223
		delegate void GetShaderiv_T(GLuint sh, GLenum pname, GLint* parm);
		static GetShaderiv_T _GetShaderiv;
pcy's avatar
initial  
pcy committed
224
225
226
		public static GLint GetShaderiv(GLuint sh, GLenum pname) {
			GLint* parm = stackalloc GLint[1];
			*parm = 0;
pcy's avatar
pcy committed
227
			_GetShaderiv(sh, pname, parm);
pcy's avatar
initial  
pcy committed
228
229
230
			return *parm;
		}

pcy's avatar
pcy committed
231
232
233
		delegate void GetShaderInfoLog_T(GLuint sh, GLsizei maxl, GLsizei* len,
				GLchar* infolog);
		static GetShaderInfoLog_T _GetShaderInfoLog;
pcy's avatar
pcy committed
234
235
236
237
238
		public static string GetShaderInfoLog(GLuint sh, GLsizei maxl) {
			GLchar[] logbuf = new GLchar[maxl];
			GLsizei len = 0;
			fixed (GLchar* logp = logbuf) {
				_GetShaderInfoLog(sh, maxl, &len, logp);
pcy's avatar
pcy committed
239
				return StrFromNullTermUTF8(logp, len);
pcy's avatar
pcy committed
240
			}
pcy's avatar
initial  
pcy committed
241
242
		}

pcy's avatar
pcy committed
243
244
		delegate void AttachShader_T(GLuint pr, GLuint sh);
		static AttachShader_T _AttachShader;
pcy's avatar
initial  
pcy committed
245
246
247
248
		public static void AttachShader(GLuint prgm, GLuint sh) {
			_AttachShader(prgm, sh);
		}

pcy's avatar
pcy committed
249
250
		delegate void LinkProgram_T(GLuint pr);
		static LinkProgram_T _LinkProgram;
pcy's avatar
initial  
pcy committed
251
252
		public static void LinkProgram(GLuint prgm) { _LinkProgram(prgm); }

pcy's avatar
pcy committed
253
254
		delegate void GetProgramiv_T(GLuint pr, GLuint pnam, GLint* parm);
		static GetProgramiv_T _GetProgramiv;
pcy's avatar
initial  
pcy committed
255
256
257
258
		// FIXME: won't work with GL_COMPUTE_WORK_GROUP_SIZE
		public static GLint GetProgramiv(GLuint prgm, GLenum pname) {
			GLint* parm = stackalloc GLint[3];
			parm[2] = parm[1] = parm[0] = 0;
pcy's avatar
pcy committed
259
			_GetProgramiv(prgm, pname, parm);
pcy's avatar
initial  
pcy committed
260
261
262
			return parm[0];
		}

pcy's avatar
pcy committed
263
264
265
		delegate void GetProgramInfoLog_T(GLuint pr, GLsizei maxl,
				GLsizei* len, GLchar* infolog);
		static GetProgramInfoLog_T _GetProgramInfoLog;
pcy's avatar
pcy committed
266
267
268
269
270
		public static string GetProgramInfoLog(GLuint prgm, GLsizei maxl) {
			GLchar[] logbuf = new GLchar[maxl];
			GLsizei len = 0;
			fixed (GLchar* logp = logbuf) {
				_GetProgramInfoLog(prgm, maxl, &len, logp);
pcy's avatar
pcy committed
271
				return StrFromNullTermUTF8(logp, len);
pcy's avatar
pcy committed
272
			}
pcy's avatar
initial  
pcy committed
273
274
		}

pcy's avatar
pcy committed
275
276
		delegate void DeleteShader_T(GLuint sh);
		static DeleteShader_T _DeleteShader;
pcy's avatar
initial  
pcy committed
277
278
		public static void DeleteShader(GLuint sh) { _DeleteShader(sh); }

pcy's avatar
pcy committed
279
280
		delegate void DeleteProgram_T(GLuint pr);
		static DeleteProgram_T _DeleteProgram;
pcy's avatar
initial  
pcy committed
281
		public static void DeleteProgram(GLuint prgm) { _DeleteProgram(prgm); }
282

pcy's avatar
pcy committed
283
284
		delegate void UseProgram_T(GLuint pr);
		static UseProgram_T _UseProgram;
285
286
		public static void UseProgram(GLuint prgm) { _UseProgram(prgm); }

pcy's avatar
pcy committed
287
288
		delegate void GetIntegerv_T(GLenum n, GLint* parm);
		static GetIntegerv_T _GetIntegerv;
289
		public static GLint GetIntegerv(GLenum name) {
pcy's avatar
pcy committed
290
			GLint* parm = stackalloc GLint[4]; // let's hope 4 is good enough
291
			parm[3] = parm[2] = parm[1] = parm[0] = 0;
pcy's avatar
pcy committed
292
			_GetIntegerv(name, parm);
293
294
			return parm[0];
		}
pcy's avatar
pcy committed
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312

		const int NAMEBUF_MAX_LEN = 64;

		delegate void GetActiveAttrib_T(GLuint prgm, GLuint idx, GLsizei bufSize,
			GLsizei* len, GLint* size, GLenum* type, GLchar* name);
		static GetActiveAttrib_T _GetActiveAttrib;
		public static void GetActiveAttrib(GLuint prgm, GLuint index,
				out GLint size, out GLSLType type, out string name) {
			GLchar* namebuf = stackalloc GLchar[NAMEBUF_MAX_LEN];
			GLsizei namelen = 0;

			size = 0;
			GLenum _typ = 0;
			fixed (GLint* psize = &size) {
				_GetActiveAttrib(prgm, index,
					(GLsizei)(NAMEBUF_MAX_LEN*sizeof(GLchar)),
					&namelen, psize, &_typ, namebuf);
			}
pcy's avatar
pcy committed
313
			name = StrFromNullTermUTF8(namebuf, namelen);
pcy's avatar
pcy committed
314
315
316
317
318
319
			type = (GLSLType)_typ;
		}

		delegate GLint GetAttribLocation_T(GLuint prgm, GLchar* name);
		static GetAttribLocation_T _GetAttribLocation;
		public static GLint GetAttribLocation(GLuint prgm, string name) {
pcy's avatar
pcy committed
320
			byte[] blargh = GetNullTermUTF8(name);
pcy's avatar
pcy committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337

			fixed (byte* bb = blargh) {
				return _GetAttribLocation(prgm, (GLchar*)bb);
			}
		}

		delegate void GetUniformIndices_T(GLuint prgm, GLsizei unifCnt,
				GLchar** unifNames, GLuint* unifIdxs);
		static GetUniformIndices_T _GetUniformIndices;
		public static void GetUniformIndices(GLuint prgm,
				string[] names, GLuint[] idxs) {
			if (names == null) throw new ArgumentNullException("names");
			if (idxs  == null) throw new ArgumentNullException("idxs" );
			if (names.Length != idxs.Length) throw new ArgumentException("#names != #idxs");

			// marshal the string array...

pcy's avatar
pcy committed
338
			// convert all the strings to utf8
pcy's avatar
pcy committed
339
340
341
			int totallen = 0;
			byte[][] bytes = new byte[names.Length][];
			for (int i = 0; i < names.Length; ++i) {
pcy's avatar
pcy committed
342
				bytes[i] = GetNullTermUTF8(names[i], true);
pcy's avatar
pcy committed
343
344
				totallen += bytes[i].Length;
			}
pcy's avatar
pcy committed
345
			// rearrange pointer crap so that glGetUniformIndices can read it
pcy's avatar
pcy committed
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
			byte[] bytesbytes = new byte[totallen];
			GLchar*[] ptrs = new GLchar*[names.Length];
			fixed (byte* bbp = bytesbytes) {
				int totalidx = 0;
				for (int i = 0; i < names.Length; ++i) {
					Array.Copy(bytes[i], 0, bytesbytes, totalidx, bytes[i].Length);
					ptrs[i] = (GLchar*)&bbp[totalidx];
					totalidx += bytes[i].Length;
				}

				// now we can actually call the function
				fixed (GLchar** strp = ptrs) {
					fixed (GLuint* idxp = idxs) {
						_GetUniformIndices(prgm, names.Length, strp, idxp);
					}
				}
			}
		}

		delegate void GetActiveUniformName_T(GLuint prgm, GLuint unifIdx,
				GLsizei bufSize, GLsizei* length, GLchar* unifName);
		static GetActiveUniformName_T _GetActiveUniformName;
		public static string GetActiveUniformName(GLuint prgm, GLuint unifIdx) {
			GLchar* namebuf = stackalloc GLchar[NAMEBUF_MAX_LEN];
			GLsizei namelen = 0;

			_GetActiveUniformName(prgm, unifIdx,
				(GLsizei)(NAMEBUF_MAX_LEN*sizeof(GLchar)),
				&namelen, namebuf);
			return new String(namebuf, 0, namelen, Encoding.UTF8);
		}

		delegate void GetActiveUniformsiv_T(GLuint prgm, GLsizei unifCnt,
				GLuint* unifIdxs, GLenum pname, GLint* parms);
		static GetActiveUniformsiv_T _GetActiveUniformsiv;
		public static void GetActiveUniformsiv(GLuint prgm,
				GLuint[] unifIdxs, GLenum pname, GLint[] parms) {
			if (unifIdxs == null) throw new ArgumentNullException("unifIdxs");
			if (parms    == null) throw new ArgumentNullException("parms"   );
			if (unifIdxs.Length != parms.Length) throw new ArgumentException("#unifIdxs != #parms");

			fixed (GLuint* idxs = unifIdxs) {
				fixed (GLint* ps = parms) {
					_GetActiveUniformsiv(prgm, parms.Length, idxs, pname, ps);
				}
			}
		}

		delegate void GetActiveUniform_T(GLuint prgm, GLuint idx, GLsizei bufSize,
				GLsizei* length, GLint* size, GLenum* type, GLchar* name);
		static GetActiveUniform_T _GetActiveUniform;
		public static void GetActiveUniform(GLuint prgm, GLuint idx,
				out GLint size, out GLSLType type, out string name) {
			GLchar* namebuf = stackalloc GLchar[NAMEBUF_MAX_LEN];
			GLsizei namelen = 0;

			size = 0;
			GLenum _typ = 0;
			fixed (GLint* psize = &size) {
				_GetActiveUniform(prgm, idx,
					(GLsizei)(NAMEBUF_MAX_LEN*sizeof(GLchar)),
					&namelen, psize, &_typ, namebuf);
			}
pcy's avatar
pcy committed
409
			name = StrFromNullTermUTF8(namebuf, namelen);
pcy's avatar
pcy committed
410
411
412
413
414
415
416
417
			type = (GLSLType)_typ;
		}

		delegate GLint GetUniformLocation_T(GLuint prgm, GLchar* name);
		static GetUniformLocation_T _GetUniformLocation;
		public static GLint GetUniformLocation(GLuint prgm, string name) {
			if (name == null) throw new ArgumentNullException("name");

pcy's avatar
pcy committed
418
			byte[] bytes = GetNullTermUTF8(name);
pcy's avatar
pcy committed
419
420
421
422
423
			fixed (byte* bp = bytes) {
				return _GetUniformLocation(prgm, (GLchar*)bp);
			}
		}

pcy's avatar
pcy committed
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
		// glUniform..() defs
		delegate void Uniform1fv_T(GLint location, GLsizei count, GLfloat* value);
		static Uniform1fv_T _Uniform1fv;
		public static void Uniform1fv(GLint location, GLsizei count, GLfloat* value) {
			_Uniform1fv(location, count, value);
		}
		delegate void Uniform2fv_T(GLint location, GLsizei count, GLfloat* value);
		static Uniform2fv_T _Uniform2fv;
		public static void Uniform2fv(GLint location, GLsizei count, GLfloat* value) {
			_Uniform2fv(location, count, value);
		}
		delegate void Uniform3fv_T(GLint location, GLsizei count, GLfloat* value);
		static Uniform3fv_T _Uniform3fv;
		public static void Uniform3fv(GLint location, GLsizei count, GLfloat* value) {
			_Uniform3fv(location, count, value);
		}
		delegate void Uniform4fv_T(GLint location, GLsizei count, GLfloat* value);
		static Uniform4fv_T _Uniform4fv;
		public static void Uniform4fv(GLint location, GLsizei count, GLfloat* value) {
			_Uniform4fv(location, count, value);
		}
		delegate void Uniform1iv_T(GLint location, GLsizei count, GLint* value);
		static Uniform1iv_T _Uniform1iv;
		public static void Uniform1iv(GLint location, GLsizei count, GLint* value) {
			_Uniform1iv(location, count, value);
		}
		delegate void Uniform2iv_T(GLint location, GLsizei count, GLint* value);
		static Uniform2iv_T _Uniform2iv;
		public static void Uniform2iv(GLint location, GLsizei count, GLint* value) {
			_Uniform2iv(location, count, value);
		}
		delegate void Uniform3iv_T(GLint location, GLsizei count, GLint* value);
		static Uniform3iv_T _Uniform3iv;
		public static void Uniform3iv(GLint location, GLsizei count, GLint* value) {
			_Uniform3iv(location, count, value);
		}
		delegate void Uniform4iv_T(GLint location, GLsizei count, GLint* value);
		static Uniform4iv_T _Uniform4iv;
		public static void Uniform4iv(GLint location, GLsizei count, GLint* value) {
			_Uniform4iv(location, count, value);
		}
		delegate void Uniform1uiv_T(GLint location, GLsizei count, GLuint* value);
		static Uniform1uiv_T _Uniform1uiv;
		public static void Uniform1uiv(GLint location, GLsizei count, GLuint* value) {
			_Uniform1uiv(location, count, value);
		}
		delegate void Uniform2uiv_T(GLint location, GLsizei count, GLuint* value);
		static Uniform2uiv_T _Uniform2uiv;
		public static void Uniform2uiv(GLint location, GLsizei count, GLuint* value) {
			_Uniform2uiv(location, count, value);
		}
		delegate void Uniform3uiv_T(GLint location, GLsizei count, GLuint* value);
		static Uniform3uiv_T _Uniform3uiv;
		public static void Uniform3uiv(GLint location, GLsizei count, GLuint* value) {
			_Uniform3uiv(location, count, value);
		}
		delegate void Uniform4uiv_T(GLint location, GLsizei count, GLuint* value);
		static Uniform4uiv_T _Uniform4uiv;
		public static void Uniform4uiv(GLint location, GLsizei count, GLuint* value) {
			_Uniform4uiv(location, count, value);
		}

		delegate void UniformMatrix2fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix2fv_T _UniformMatrix2fv;
		public static void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix2fv(location, count, transpose, value);
		}
		delegate void UniformMatrix3fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix3fv_T _UniformMatrix3fv;
		public static void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix3fv(location, count, transpose, value);
		}
		delegate void UniformMatrix4fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix4fv_T _UniformMatrix4fv;
		public static void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix4fv(location, count, transpose, value);
		}
		delegate void UniformMatrix2x3fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix2x3fv_T _UniformMatrix2x3fv;
		public static void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix2x3fv(location, count, transpose, value);
		}
		delegate void UniformMatrix3x2fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix3x2fv_T _UniformMatrix3x2fv;
		public static void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix3x2fv(location, count, transpose, value);
		}
		delegate void UniformMatrix2x4fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix2x4fv_T _UniformMatrix2x4fv;
		public static void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix2x4fv(location, count, transpose, value);
		}
		delegate void UniformMatrix4x2fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix4x2fv_T _UniformMatrix4x2fv;
		public static void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix4x2fv(location, count, transpose, value);
		}
		delegate void UniformMatrix3x4fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix3x4fv_T _UniformMatrix3x4fv;
		public static void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix3x4fv(location, count, transpose, value);
		}
		delegate void UniformMatrix4x3fv_T(GLint location, GLsizei count, GLboolean transpose, GLfloat* value);
		static UniformMatrix4x3fv_T _UniformMatrix4x3fv;
		public static void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, GLfloat* value) {
			_UniformMatrix4x3fv(location, count, transpose, value);
		}
pcy's avatar
pcy committed
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


		delegate void Uniform1f_T(GLint location, GLfloat v0);
		static Uniform1f_T _Uniform1f;
		public static void Uniform1f(GLint location, GLfloat v0) {
			_Uniform1f(location, v0);
		}

		delegate void Uniform2f_T(GLint location, GLfloat v0, GLfloat v1);
		static Uniform2f_T _Uniform2f;
		public static void Uniform2f(GLint location, GLfloat v0, GLfloat v1) {
			_Uniform2f(location, v0, v1);
		}

		delegate void Uniform3f_T(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
		static Uniform3f_T _Uniform3f;
		public static void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
			_Uniform3f(location, v0, v1, v2);
		}

		delegate void Uniform4f_T(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
		static Uniform4f_T _Uniform4f;
		public static void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
			_Uniform4f(location, v0, v1, v2, v3);
		}

		delegate void Uniform1i_T(GLint location, GLint v0);
		static Uniform1i_T _Uniform1i;
		public static void Uniform1i(GLint location, GLint v0) {
			_Uniform1i(location, v0);
		}

		delegate void Uniform2i_T(GLint location, GLint v0, GLint v1);
		static Uniform2i_T _Uniform2i;
		public static void Uniform2i(GLint location, GLint v0, GLint v1) {
			_Uniform2i(location, v0, v1);
		}

		delegate void Uniform3i_T(GLint location, GLint v0, GLint v1, GLint v2);
		static Uniform3i_T _Uniform3i;
		public static void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
			_Uniform3i(location, v0, v1, v2);
		}

		delegate void Uniform4i_T(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
		static Uniform4i_T _Uniform4i;
		public static void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
			_Uniform4i(location, v0, v1, v2, v3);
		}

		delegate void Uniform1ui_T(GLint location, GLuint v0);
		static Uniform1ui_T _Uniform1ui;
		public static void Uniform1ui(GLint location, GLuint v0) {
			_Uniform1ui(location, v0);
		}

		delegate void Uniform2ui_T(GLint location, GLuint v0, GLuint v1);
		static Uniform2ui_T _Uniform2ui;
		public static void Uniform2ui(GLint location, GLuint v0, GLuint v1) {
			_Uniform2ui(location, v0, v1);
		}

		delegate void Uniform3ui_T(GLint location, GLuint v0, GLuint v1, GLuint v2);
		static Uniform3ui_T _Uniform3ui;
		public static void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) {
			_Uniform3ui(location, v0, v1, v2);
		}

		delegate void Uniform4ui_T(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
		static Uniform4ui_T _Uniform4ui;
		public static void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
			_Uniform4ui(location, v0, v1, v2, v3);
		}
pcy's avatar
pcy committed
604
605
606
607
608
609
610
611
612
613

		delegate void ActiveTexture_T(GLenum tex);
		static ActiveTexture_T _ActiveTexture;
		public static void ActiveTexture(GLenum tex) { _ActiveTexture(tex); }

		delegate void BindTexture_T(GLenum tar, GLuint tex);
		static BindTexture_T _BindTexture;
		public static void BindTexture(GLenum tar, GLuint tex) {
			_BindTexture(tar, tex);
		}
pcy's avatar
pcy committed
614
615
616
617
618
619
620
621

		delegate void Enable_T(GLenum cap);
		static Enable_T _Enable;
		public static void Enable(GLenum cap) { _Enable(cap); }

		delegate void Disable_T(GLenum cap);
		static Disable_T _Disable;
		public static void Disable(GLenum cap) { _Disable(cap); }
pcy's avatar
lol    
pcy committed
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640

		public delegate void DEBUGPROC(GLenum src, GLenum typ, GLuint id,
				GLenum sev, GLsizei len, GLchar* msg, IntPtr ud);
		/*public delegate void DEBUGPROC_mgd(GLenum src, GLenum typ, GLuint id,
				GLenum sev, string msg, IntPtr ud);*/

		delegate void DebugMessageCallback_T(IntPtr cb, IntPtr ud);
		static DebugMessageCallback_T _DebugMessageCallback;
		public static void DebugMessageCallback(DEBUGPROC cb, IntPtr ud) {
			if (_DebugMessageCallback != null)
				_DebugMessageCallback(Marshal.GetFunctionPointerForDelegate(cb), ud);
		}

		delegate void DebugMessageControl_T(GLenum src, GLenum typ, GLenum sev, GLsizei cnt, GLuint* ids, GLboolean en);
		static DebugMessageControl_T _DebugMessageControl;
		public static void DebugMessageControl(GLenum src, GLenum typ, GLenum sev, GLsizei cnt, GLuint* ids, GLboolean en) {
			if (_DebugMessageControl != null)
				_DebugMessageControl(src, typ, sev, cnt, ids, en);
		}
pcy's avatar
initial  
pcy committed
641
642
643
	}
}