Merge branch 'master' into blender2.8
[blender.git] / source / blender / python / generic / bgl.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Willian P. Germano, Campbell Barton
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/python/generic/bgl.c
24  *  \ingroup pygen
25  *
26  * This file is the 'bgl' module which wraps OpenGL functions and constants,
27  * allowing script writers to make OpenGL calls in their Python scripts.
28  *
29  * \note
30  * This module is very similar to 'PyOpenGL' which could replace 'bgl' one day.
31  */
32
33 #include <Python.h>
34
35 #include "BLI_utildefines.h"
36
37 #include "GPU_glew.h"
38 #include "MEM_guardedalloc.h"
39
40 #include "bgl.h"
41
42
43 /* -------------------------------------------------------------------- */
44
45 /** \name Local utility defines for wrapping OpenGL
46  * \{ */
47
48 /*@ By golly George! It looks like fancy pants macro time!!! */
49
50
51 /* TYPE_str is the string to pass to Py_ArgParse (for the format) */
52 /* TYPE_var is the name to pass to the GL function */
53 /* TYPE_ref is the pointer to pass to Py_ArgParse (to store in) */
54 /* TYPE_def is the C initialization of the variable */
55
56 #define void_str      ""
57 #define void_var(num)
58 #define void_ref(num)   &bgl_var##num
59 #define void_def(num)   char bgl_var##num
60
61 #if 0
62 #define buffer_str "O!"
63 #define buffer_var(number)  (bgl_buffer##number)->buf.asvoid
64 #define buffer_ref(number)  &BGL_bufferType, &bgl_buffer##number
65 #define buffer_def(number)  Buffer *bgl_buffer##number
66 #endif
67
68 /* GL Pointer fields, handled by buffer type */
69 /* GLdoubleP, GLfloatP, GLintP, GLuintP, GLshortP, GLsizeiP, GLcharP */
70
71 #define GLbooleanP_str      "O!"
72 #define GLbooleanP_var(number)  (bgl_buffer##number)->buf.asvoid
73 #define GLbooleanP_ref(number)  &BGL_bufferType, &bgl_buffer##number
74 #define GLbooleanP_def(number)  Buffer *bgl_buffer##number
75
76 #define GLbyteP_str     "O!"
77 #define GLbyteP_var(number) (bgl_buffer##number)->buf.asvoid
78 #define GLbyteP_ref(number) &BGL_bufferType, &bgl_buffer##number
79 #define GLbyteP_def(number) Buffer *bgl_buffer##number
80
81 #define GLubyteP_str      "O!"
82 #define GLubyteP_var(number)  (bgl_buffer##number)->buf.asvoid
83 #define GLubyteP_ref(number)  &BGL_bufferType, &bgl_buffer##number
84 #define GLubyteP_def(number)  Buffer *bgl_buffer##number
85
86 #define GLintP_str      "O!"
87 #define GLintP_var(number)  (bgl_buffer##number)->buf.asvoid
88 #define GLintP_ref(number)  &BGL_bufferType, &bgl_buffer##number
89 #define GLintP_def(number)  Buffer *bgl_buffer##number
90
91 #define GLint64P_str      "O!"
92 #define GLint64P_var(number)  (bgl_buffer##number)->buf.asvoid
93 #define GLint64P_ref(number)  &BGL_bufferType, &bgl_buffer##number
94 #define GLint64P_def(number)  Buffer *bgl_buffer##number
95
96 #define GLenumP_str      "O!"
97 #define GLenumP_var(number)  (bgl_buffer##number)->buf.asvoid
98 #define GLenumP_ref(number)  &BGL_bufferType, &bgl_buffer##number
99 #define GLenumP_def(number)  Buffer *bgl_buffer##number
100
101 #define GLuintP_str     "O!"
102 #define GLuintP_var(number) (bgl_buffer##number)->buf.asvoid
103 #define GLuintP_ref(number) &BGL_bufferType, &bgl_buffer##number
104 #define GLuintP_def(number) Buffer *bgl_buffer##number
105
106 #if 0
107 #define GLuint64P_str     "O!"
108 #define GLuint64P_var(number) (bgl_buffer##number)->buf.asvoid
109 #define GLuint64P_ref(number) &BGL_bufferType, &bgl_buffer##number
110 #define GLuint64P_def(number) Buffer *bgl_buffer##number
111 #endif
112
113 #define GLshortP_str      "O!"
114 #define GLshortP_var(number)  (bgl_buffer##number)->buf.asvoid
115 #define GLshortP_ref(number)  &BGL_bufferType, &bgl_buffer##number
116 #define GLshortP_def(number)  Buffer *bgl_buffer##number
117
118 #define GLushortP_str     "O!"
119 #define GLushortP_var(number) (bgl_buffer##number)->buf.asvoid
120 #define GLushortP_ref(number) &BGL_bufferType, &bgl_buffer##number
121 #define GLushortP_def(number) Buffer *bgl_buffer##number
122
123 #define GLfloatP_str      "O!"
124 #define GLfloatP_var(number)  (bgl_buffer##number)->buf.asvoid
125 #define GLfloatP_ref(number)  &BGL_bufferType, &bgl_buffer##number
126 #define GLfloatP_def(number)  Buffer *bgl_buffer##number
127
128 #define GLdoubleP_str     "O!"
129 #define GLdoubleP_var(number) (bgl_buffer##number)->buf.asvoid
130 #define GLdoubleP_ref(number) &BGL_bufferType, &bgl_buffer##number
131 #define GLdoubleP_def(number) Buffer *bgl_buffer##number
132
133 #if 0
134 #define GLclampfP_str     "O!"
135 #define GLclampfP_var(number) (bgl_buffer##number)->buf.asvoid
136 #define GLclampfP_ref(number) &BGL_bufferType, &bgl_buffer##number
137 #define GLclampfP_def(number) Buffer *bgl_buffer##number
138 #endif
139
140 #define GLvoidP_str     "O!"
141 #define GLvoidP_var(number) (bgl_buffer##number)->buf.asvoid
142 #define GLvoidP_ref(number) &BGL_bufferType, &bgl_buffer##number
143 #define GLvoidP_def(number) Buffer *bgl_buffer##number
144
145 #define GLsizeiP_str     "O!"
146 #define GLsizeiP_var(number) (bgl_buffer##number)->buf.asvoid
147 #define GLsizeiP_ref(number) &BGL_bufferType, &bgl_buffer##number
148 #define GLsizeiP_def(number) Buffer *bgl_buffer##number
149
150 #define GLcharP_str     "O!"
151 #define GLcharP_var(number) (bgl_buffer##number)->buf.asvoid
152 #define GLcharP_ref(number) &BGL_bufferType, &bgl_buffer##number
153 #define GLcharP_def(number) Buffer *bgl_buffer##number
154
155 #if 0
156 #define buffer_str      "O!"
157 #define buffer_var(number)  (bgl_buffer##number)->buf.asvoid
158 #define buffer_ref(number)  &BGL_bufferType, &bgl_buffer##number
159 #define buffer_def(number)  Buffer *bgl_buffer##number
160 #endif
161
162 /*@The standard GL typedefs are used as prototypes, we can't
163  * use the GL type directly because Py_ArgParse expects normal
164  * C types.
165  *
166  * Py_ArgParse doesn't grok writing into unsigned variables,
167  * so we use signed everything (even stuff that should be unsigned.
168  */
169
170 /* typedef unsigned int GLenum; */
171 #define GLenum_str      "i"
172 #define GLenum_var(num)   bgl_var##num
173 #define GLenum_ref(num)   &bgl_var##num
174 #define GLenum_def(num)   /* unsigned */ int GLenum_var(num)
175
176 /* typedef unsigned int GLboolean; */
177 #define GLboolean_str     "b"
178 #define GLboolean_var(num)    bgl_var##num
179 #define GLboolean_ref(num)    &bgl_var##num
180 #define GLboolean_def(num)    /* unsigned */ char GLboolean_var(num)
181
182 /* typedef unsigned int GLbitfield; */
183 #define GLbitfield_str      "i"
184 #define GLbitfield_var(num)   bgl_var##num
185 #define GLbitfield_ref(num)   &bgl_var##num
186 #define GLbitfield_def(num)   /* unsigned */ int GLbitfield_var(num)
187
188 #if 0
189 /* typedef signed char GLbyte; */
190 #define GLbyte_str        "b"
191 #define GLbyte_var(num)     bgl_var##num
192 #define GLbyte_ref(num)     &bgl_var##num
193 #define GLbyte_def(num)     signed char GLbyte_var(num)
194 #endif
195
196 /* typedef short GLshort; */
197 #define GLshort_str       "h"
198 #define GLshort_var(num)    bgl_var##num
199 #define GLshort_ref(num)    &bgl_var##num
200 #define GLshort_def(num)    short GLshort_var(num)
201
202 /* typedef int GLint; */
203 #define GLint_str       "i"
204 #define GLint_var(num)      bgl_var##num
205 #define GLint_ref(num)      &bgl_var##num
206 #define GLint_def(num)      int GLint_var(num)
207
208 /* typedef int GLsizei; */
209 #define GLsizei_str       "n"
210 #define GLsizei_var(num)    bgl_var##num
211 #define GLsizei_ref(num)    &bgl_var##num
212 #define GLsizei_def(num)    size_t GLsizei_var(num)
213
214 /* typedef int GLsizeiptr; */
215 #define GLsizeiptr_str       "n"
216 #define GLsizeiptr_var(num)    bgl_var##num
217 #define GLsizeiptr_ref(num)    &bgl_var##num
218 #define GLsizeiptr_def(num)    size_t GLsizeiptr_var(num)
219
220 /* typedef int GLintptr; */
221 #define GLintptr_str       "n"
222 #define GLintptr_var(num)    bgl_var##num
223 #define GLintptr_ref(num)    &bgl_var##num
224 #define GLintptr_def(num)    size_t GLintptr_var(num)
225
226 /* typedef unsigned char GLubyte; */
227 #define GLubyte_str       "B"
228 #define GLubyte_var(num)    bgl_var##num
229 #define GLubyte_ref(num)    &bgl_var##num
230 #define GLubyte_def(num)    /* unsigned */ char GLubyte_var(num)
231
232 #if 0
233 /* typedef unsigned short GLushort; */
234 #define GLushort_str      "H"
235 #define GLushort_var(num)   bgl_var##num
236 #define GLushort_ref(num)   &bgl_var##num
237 #define GLushort_def(num)   /* unsigned */ short GLushort_var(num)
238 #endif
239
240 /* typedef unsigned int GLuint; */
241 #define GLuint_str        "I"
242 #define GLuint_var(num)     bgl_var##num
243 #define GLuint_ref(num)     &bgl_var##num
244 #define GLuint_def(num)     /* unsigned */ int GLuint_var(num)
245
246 /* typedef unsigned int GLuint64; */
247 #if 0
248 #define GLuint64_str        "Q"
249 #define GLuint64_var(num)     bgl_var##num
250 #define GLuint64_ref(num)     &bgl_var##num
251 #define GLuint64_def(num)     /* unsigned */ int GLuint64_var(num)
252 #endif
253
254 /* typedef unsigned int GLsync; */
255 #if 0
256 #define GLsync_str        "I"
257 #define GLsync_var(num)     bgl_var##num
258 #define GLsync_ref(num)     &bgl_var##num
259 #define GLsync_def(num)     /* unsigned */ int GLsync_var(num)
260 #endif
261
262 /* typedef float GLfloat; */
263 #define GLfloat_str       "f"
264 #define GLfloat_var(num)    bgl_var##num
265 #define GLfloat_ref(num)    &bgl_var##num
266 #define GLfloat_def(num)    float GLfloat_var(num)
267
268 /* typedef char *GLstring; */
269 #define GLstring_str     "s"
270 #define GLstring_var(number) bgl_var##number
271 #define GLstring_ref(number) &bgl_var##number
272 #define GLstring_def(number) char *GLstring_var(number)
273
274 /* typedef float GLclampf; */
275 #if 0
276 #define GLclampf_str      "f"
277 #define GLclampf_var(num)   bgl_var##num
278 #define GLclampf_ref(num)   &bgl_var##num
279 #define GLclampf_def(num)   float GLclampf_var(num)
280 #endif
281
282 /* typedef double GLdouble; */
283 #define GLdouble_str      "d"
284 #define GLdouble_var(num)   bgl_var##num
285 #define GLdouble_ref(num)   &bgl_var##num
286 #define GLdouble_def(num)   double GLdouble_var(num)
287
288 /* typedef double GLclampd; */
289 #if 0
290 #define GLclampd_str      "d"
291 #define GLclampd_var(num)   bgl_var##num
292 #define GLclampd_ref(num)   &bgl_var##num
293 #define GLclampd_def(num)   double GLclampd_var(num)
294 #endif
295
296 #define _arg_def1(a1) \
297                    a1##_def(1)
298 #define _arg_def2(a1, a2) \
299         _arg_def1(a1); a2##_def(2)
300 #define _arg_def3(a1, a2, a3) \
301         _arg_def2(a1, a2); a3##_def(3)
302 #define _arg_def4(a1, a2, a3, a4) \
303         _arg_def3(a1, a2, a3); a4##_def(4)
304 #define _arg_def5(a1, a2, a3, a4, a5) \
305         _arg_def4(a1, a2, a3, a4); a5##_def(5)
306 #define _arg_def6(a1, a2, a3, a4, a5, a6) \
307         _arg_def5(a1, a2, a3, a4, a5); a6##_def(6)
308 #define _arg_def7(a1, a2, a3, a4, a5, a6, a7) \
309         _arg_def6(a1, a2, a3, a4, a5, a6); a7##_def(7)
310 #define _arg_def8(a1, a2, a3, a4, a5, a6, a7, a8) \
311         _arg_def7(a1, a2, a3, a4, a5, a6, a7); a8##_def(8)
312 #define _arg_def9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
313         _arg_def8(a1, a2, a3, a4, a5, a6, a7, a8); a9##_def(9)
314 #define _arg_def10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
315         _arg_def9(a1, a2, a3, a4, a5, a6, a7, a8, a9); a10##_def(10)
316 #define _arg_def11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
317         _arg_def10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); a11##_def(11)
318 #define  arg_def(...) VA_NARGS_CALL_OVERLOAD(_arg_def, __VA_ARGS__)
319
320 #define _arg_var1(a1) \
321                 a1##_var(1)
322 #define _arg_var2(a1, a2) \
323         _arg_var1(a1), a2##_var(2)
324 #define _arg_var3(a1, a2, a3) \
325         _arg_var2(a1, a2), a3##_var(3)
326 #define _arg_var4(a1, a2, a3, a4) \
327         _arg_var3(a1, a2, a3), a4##_var(4)
328 #define _arg_var5(a1, a2, a3, a4, a5) \
329         _arg_var4(a1, a2, a3, a4), a5##_var(5)
330 #define _arg_var6(a1, a2, a3, a4, a5, a6) \
331         _arg_var5(a1, a2, a3, a4, a5), a6##_var(6)
332 #define _arg_var7(a1, a2, a3, a4, a5, a6, a7) \
333         _arg_var6(a1, a2, a3, a4, a5, a6), a7##_var(7)
334 #define _arg_var8(a1, a2, a3, a4, a5, a6, a7, a8) \
335         _arg_var7(a1, a2, a3, a4, a5, a6, a7), a8##_var(8)
336 #define _arg_var9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
337         _arg_var8(a1, a2, a3, a4, a5, a6, a7, a8), a9##_var(9)
338 #define _arg_var10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
339         _arg_var9(a1, a2, a3, a4, a5, a6, a7, a8, a9), a10##_var(10)
340 #define _arg_var11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
341         _arg_var10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10), a11##_var(11)
342 #define  arg_var(...) VA_NARGS_CALL_OVERLOAD(_arg_var, __VA_ARGS__)
343
344 #define _arg_ref1(a1) \
345                    a1##_ref(1)
346 #define _arg_ref2(a1, a2) \
347         _arg_ref1(a1), a2##_ref(2)
348 #define _arg_ref3(a1, a2, a3) \
349         _arg_ref2(a1, a2), a3##_ref(3)
350 #define _arg_ref4(a1, a2, a3, a4) \
351         _arg_ref3(a1, a2, a3), a4##_ref(4)
352 #define _arg_ref5(a1, a2, a3, a4, a5) \
353         _arg_ref4(a1, a2, a3, a4), a5##_ref(5)
354 #define _arg_ref6(a1, a2, a3, a4, a5, a6) \
355         _arg_ref5(a1, a2, a3, a4, a5), a6##_ref(6)
356 #define _arg_ref7(a1, a2, a3, a4, a5, a6, a7) \
357         _arg_ref6(a1, a2, a3, a4, a5, a6), a7##_ref(7)
358 #define _arg_ref8(a1, a2, a3, a4, a5, a6, a7, a8) \
359         _arg_ref7(a1, a2, a3, a4, a5, a6, a7), a8##_ref(8)
360 #define _arg_ref9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
361         _arg_ref8(a1, a2, a3, a4, a5, a6, a7, a8), a9##_ref(9)
362 #define _arg_ref10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
363         _arg_ref9(a1, a2, a3, a4, a5, a6, a7, a8, a9), a10##_ref(10)
364 #define _arg_ref11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
365         _arg_ref10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10), a11##_ref(11)
366 #define  arg_ref(...) VA_NARGS_CALL_OVERLOAD(_arg_ref, __VA_ARGS__)
367
368 #define _arg_str1(a1) \
369                   a1##_str
370 #define _arg_str2(a1, a2) \
371         _arg_str1(a1) a2##_str
372 #define _arg_str3(a1, a2, a3) \
373         _arg_str2(a1, a2) a3##_str
374 #define _arg_str4(a1, a2, a3, a4) \
375         _arg_str3(a1, a2, a3) a4##_str
376 #define _arg_str5(a1, a2, a3, a4, a5) \
377         _arg_str4(a1, a2, a3, a4) a5##_str
378 #define _arg_str6(a1, a2, a3, a4, a5, a6) \
379         _arg_str5(a1, a2, a3, a4, a5) a6##_str
380 #define _arg_str7(a1, a2, a3, a4, a5, a6, a7) \
381         _arg_str6(a1, a2, a3, a4, a5, a6) a7##_str
382 #define _arg_str8(a1, a2, a3, a4, a5, a6, a7, a8) \
383         _arg_str7(a1, a2, a3, a4, a5, a6, a7) a8##_str
384 #define _arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
385         _arg_str8(a1, a2, a3, a4, a5, a6, a7, a8) a9##_str
386 #define _arg_str10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
387         _arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9) a10##_str
388 #define _arg_str11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
389         _arg_str10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) a11##_str
390 #define  arg_str(...) VA_NARGS_CALL_OVERLOAD(_arg_str, __VA_ARGS__)
391
392 #define ret_def_void
393 #define ret_set_void
394 #define ret_ret_void    return Py_INCREF(Py_None), Py_None
395
396 #define ret_def_GLint   int ret_int
397 #define ret_set_GLint   ret_int =
398 #define ret_ret_GLint   return PyLong_FromLong(ret_int)
399
400 #define ret_def_GLuint    unsigned int ret_uint
401 #define ret_set_GLuint    ret_uint =
402 #define ret_ret_GLuint    return PyLong_FromLong((long) ret_uint)
403
404 #if 0
405 #define ret_def_GLsizei   size_t ret_size_t
406 #define ret_set_GLsizei   ret_size_t =
407 #define ret_ret_GLsizei   return PyLong_FromSsize_t(ret_size_t)
408 #endif
409
410 #if 0
411 #define ret_def_GLsync    unsigned int ret_sync
412 #define ret_set_GLsync    ret_sync =
413 #define ret_ret_GLsync    return PyLong_FromLong((long) ret_sync)
414 #endif
415
416 #define ret_def_GLenum    unsigned int ret_uint
417 #define ret_set_GLenum    ret_uint =
418 #define ret_ret_GLenum    return PyLong_FromLong((long) ret_uint)
419
420 #define ret_def_GLboolean unsigned char ret_bool
421 #define ret_set_GLboolean ret_bool =
422 #define ret_ret_GLboolean return PyLong_FromLong((long) ret_bool)
423
424 #define ret_def_GLstring  const unsigned char *ret_str
425 #define ret_set_GLstring  ret_str =
426
427 #define ret_ret_GLstring                                                      \
428         if (ret_str) {                                                            \
429                 return PyUnicode_FromString((const char *)ret_str);                   \
430         }                                                                         \
431         else {                                                                    \
432                 PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \
433                 return NULL;                                                          \
434         }                                                                         \
435
436 /** \} */
437
438
439 /* -------------------------------------------------------------------- */
440 /* Forward Declarations */
441
442 static PyObject *Buffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
443 static PyObject *Method_ShaderSource(PyObject *self, PyObject *args);
444
445 /* Buffer sequence methods */
446
447 static int Buffer_len(Buffer *self);
448 static PyObject *Buffer_item(Buffer *self, int i);
449 static PyObject *Buffer_slice(Buffer *self, int begin, int end);
450 static int Buffer_ass_item(Buffer *self, int i, PyObject *v);
451 static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq);
452 static PyObject *Buffer_subscript(Buffer *self, PyObject *item);
453 static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value);
454
455
456 /* -------------------------------------------------------------------- */
457
458 /** \name Utility Functions
459  * \{ */
460
461
462 int BGL_typeSize(int type)
463 {
464         switch (type) {
465                 case GL_BYTE:
466                         return sizeof(char);
467                 case GL_SHORT:
468                         return sizeof(short);
469                 case GL_INT:
470                         return sizeof(int);
471                 case GL_FLOAT:
472                         return sizeof(float);
473                 case GL_DOUBLE:
474                         return sizeof(double);
475         }
476         return -1;
477 }
478
479 static int gl_buffer_type_from_py_format_char(char *typestr)
480 {
481         if (ELEM(typestr[0], '<', '>', '|')) {
482                 typestr += 1;
483         }
484         char format = typestr[0];
485         char byte_num = typestr[1];
486
487         switch (format) {
488                 case 't':
489                 case 'b':
490                 case 'h':
491                         if (!byte_num) return GL_BYTE;
492                         ATTR_FALLTHROUGH;
493                 case 'i':
494                         if (!byte_num) return GL_SHORT;
495                         ATTR_FALLTHROUGH;
496                 case 'l':
497                         if (!byte_num || byte_num == '4') return GL_INT;
498                         if (byte_num == '1') return GL_BYTE;
499                         if (byte_num == '2') return GL_SHORT;
500                         break;
501                 case 'f':
502                         if (!byte_num) return GL_FLOAT;
503                         ATTR_FALLTHROUGH;
504                 case 'd':
505                         if (!byte_num || byte_num == '8') return GL_DOUBLE;
506                         if (byte_num == '4') return GL_FLOAT;
507                         break;
508         }
509         return -1; /* UNKNOWN */
510 }
511
512 static bool compare_dimensions(int ndim, int *dim1, Py_ssize_t *dim2)
513 {
514         for (int i = 0; i < ndim; i++) {
515                 if (dim1[i] != dim2[i]) {
516                         return false;
517                 }
518         }
519         return true;
520 }
521
522 /** \} */
523
524
525 /* -------------------------------------------------------------------- */
526
527 /** \name Buffer API
528  * \{ */
529
530 static PySequenceMethods Buffer_SeqMethods = {
531         (lenfunc) Buffer_len,                       /*sq_length */
532         (binaryfunc) NULL,                          /*sq_concat */
533         (ssizeargfunc) NULL,                        /*sq_repeat */
534         (ssizeargfunc) Buffer_item,                 /*sq_item */
535         (ssizessizeargfunc) NULL,                   /*sq_slice, deprecated, handled in Buffer_item */
536         (ssizeobjargproc) Buffer_ass_item,          /*sq_ass_item */
537         (ssizessizeobjargproc) NULL,                /*sq_ass_slice, deprecated handled in Buffer_ass_item */
538         (objobjproc) NULL,                          /* sq_contains */
539         (binaryfunc) NULL,                          /* sq_inplace_concat */
540         (ssizeargfunc) NULL,                        /* sq_inplace_repeat */
541 };
542
543
544 static PyMappingMethods Buffer_AsMapping = {
545         (lenfunc)Buffer_len,
546         (binaryfunc)Buffer_subscript,
547         (objobjargproc)Buffer_ass_subscript
548 };
549
550 static void Buffer_dealloc(Buffer *self);
551 static PyObject *Buffer_repr(Buffer *self);
552
553 static PyObject *Buffer_to_list(Buffer *self)
554 {
555         int i, len = self->dimensions[0];
556         PyObject *list = PyList_New(len);
557
558         for (i = 0; i < len; i++) {
559                 PyList_SET_ITEM(list, i, Buffer_item(self, i));
560         }
561
562         return list;
563 }
564
565 static PyObject *Buffer_to_list_recursive(Buffer *self)
566 {
567         PyObject *list;
568
569         if (self->ndimensions > 1) {
570                 int i, len = self->dimensions[0];
571                 list = PyList_New(len);
572
573                 for (i = 0; i < len; i++) {
574                         Buffer *sub = (Buffer *)Buffer_item(self, i);
575                         PyList_SET_ITEM(list, i, Buffer_to_list_recursive(sub));
576                         Py_DECREF(sub);
577                 }
578         }
579         else {
580                 list = Buffer_to_list(self);
581         }
582
583         return list;
584 }
585
586 static PyObject *Buffer_dimensions(Buffer *self, void *UNUSED(arg))
587 {
588         PyObject *list = PyList_New(self->ndimensions);
589         int i;
590
591         for (i = 0; i < self->ndimensions; i++) {
592                 PyList_SET_ITEM(list, i, PyLong_FromLong(self->dimensions[i]));
593         }
594
595         return list;
596 }
597
598 static PyMethodDef Buffer_methods[] = {
599         {"to_list", (PyCFunction)Buffer_to_list_recursive, METH_NOARGS,
600          "return the buffer as a list"},
601         {NULL, NULL, 0, NULL}
602 };
603
604 static PyGetSetDef Buffer_getseters[] = {
605         {(char *)"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL},
606         {NULL, NULL, NULL, NULL, NULL}
607 };
608
609
610 PyTypeObject BGL_bufferType = {
611         PyVarObject_HEAD_INIT(NULL, 0)
612         "bgl.Buffer",               /*tp_name */
613         sizeof(Buffer),             /*tp_basicsize */
614         0,                          /*tp_itemsize */
615         (destructor)Buffer_dealloc, /*tp_dealloc */
616         (printfunc)NULL,            /*tp_print */
617         NULL,                       /*tp_getattr */
618         NULL,                       /*tp_setattr */
619         NULL,                       /*tp_compare */
620         (reprfunc) Buffer_repr,     /*tp_repr */
621         NULL,                       /*tp_as_number */
622         &Buffer_SeqMethods,         /*tp_as_sequence */
623         &Buffer_AsMapping,          /* PyMappingMethods *tp_as_mapping; */
624
625         /* More standard operations (here for binary compatibility) */
626
627         NULL, /* hashfunc tp_hash; */
628         NULL,                       /* ternaryfunc tp_call; */
629         NULL,                       /* reprfunc tp_str; */
630         NULL,                       /* getattrofunc tp_getattro; */
631         NULL,                       /* setattrofunc tp_setattro; */
632
633         /* Functions to access object as input/output buffer */
634         NULL,                       /* PyBufferProcs *tp_as_buffer; */
635
636         /*** Flags to define presence of optional/expanded features ***/
637         Py_TPFLAGS_DEFAULT,         /* long tp_flags; */
638
639         NULL,                       /*  char *tp_doc;  Documentation string */
640         /*** Assigned meaning in release 2.0 ***/
641         /* call function for all accessible objects */
642         NULL,                       /* traverseproc tp_traverse; */
643
644         /* delete references to contained objects */
645         NULL,                       /* inquiry tp_clear; */
646
647         /***  Assigned meaning in release 2.1 ***/
648         /*** rich comparisons ***/
649         NULL,                       /* richcmpfunc tp_richcompare; */
650
651         /***  weak reference enabler ***/
652         0,                          /* long tp_weaklistoffset; */
653
654         /*** Added in release 2.2 ***/
655         /*   Iterators */
656         NULL, /* getiterfunc tp_iter; */
657         NULL,                       /* iternextfunc tp_iternext; */
658         /*** Attribute descriptor and subclassing stuff ***/
659         Buffer_methods,             /* struct PyMethodDef *tp_methods; */
660         NULL,                       /* struct PyMemberDef *tp_members; */
661         Buffer_getseters,           /* struct PyGetSetDef *tp_getset; */
662         NULL,                       /*tp_base*/
663         NULL,                       /*tp_dict*/
664         NULL,                       /*tp_descr_get*/
665         NULL,                       /*tp_descr_set*/
666         0,                          /*tp_dictoffset*/
667         NULL,                       /*tp_init*/
668         NULL,                       /*tp_alloc*/
669         Buffer_new,                 /*tp_new*/
670         NULL,                       /*tp_free*/
671         NULL,                       /*tp_is_gc*/
672         NULL,                       /*tp_bases*/
673         NULL,                       /*tp_mro*/
674         NULL,                       /*tp_cache*/
675         NULL,                       /*tp_subclasses*/
676         NULL,                       /*tp_weaklist*/
677         NULL                        /*tp_del*/
678 };
679
680
681 static Buffer *BGL_MakeBuffer_FromData(PyObject *parent, int type, int ndimensions, int *dimensions, void *buf)
682 {
683         Buffer *buffer = (Buffer *)PyObject_NEW(Buffer, &BGL_bufferType);
684
685         Py_XINCREF(parent);
686         buffer->parent = parent;
687         buffer->ndimensions = ndimensions;
688         buffer->dimensions = MEM_mallocN(ndimensions * sizeof(int), "Buffer dimensions");
689         memcpy(buffer->dimensions, dimensions, ndimensions * sizeof(int));
690         buffer->type = type;
691         buffer->buf.asvoid = buf;
692
693         return buffer;
694 }
695
696 /**
697  * Create a buffer object
698  *
699  * \param dimensions: An array of ndimensions integers representing the size of each dimension.
700  * \param initbuffer: When not NULL holds a contiguous buffer
701  * with the correct format from which the buffer will be initialized
702  */
703 Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuffer)
704 {
705         Buffer *buffer;
706         void *buf = NULL;
707         int i, size = BGL_typeSize(type);
708
709         for (i = 0; i < ndimensions; i++) {
710                 size *= dimensions[i];
711         }
712
713         buf = MEM_mallocN(size, "Buffer buffer");
714
715         buffer = BGL_MakeBuffer_FromData(NULL, type, ndimensions, dimensions, buf);
716
717         if (initbuffer) {
718                 memcpy(buffer->buf.asvoid, initbuffer, size);
719         }
720         else {
721                 memset(buffer->buf.asvoid, 0, size);
722         }
723         return buffer;
724 }
725
726
727 #define MAX_DIMENSIONS  256
728 static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
729 {
730         PyObject *length_ob = NULL, *init = NULL;
731         Buffer *buffer = NULL;
732         int dimensions[MAX_DIMENSIONS];
733
734         int type;
735         Py_ssize_t i, ndimensions = 0;
736
737         if (kwds && PyDict_Size(kwds)) {
738                 PyErr_SetString(PyExc_TypeError,
739                                 "bgl.Buffer(): takes no keyword args");
740                 return NULL;
741         }
742
743         if (!PyArg_ParseTuple(args, "iO|O: bgl.Buffer", &type, &length_ob, &init)) {
744                 return NULL;
745         }
746         if (!ELEM(type, GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE)) {
747                 PyErr_SetString(PyExc_AttributeError,
748                                 "invalid first argument type, should be one of "
749                                 "GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT or GL_DOUBLE");
750                 return NULL;
751         }
752
753         if (PyLong_Check(length_ob)) {
754                 ndimensions = 1;
755                 if (((dimensions[0] = PyLong_AsLong(length_ob)) < 1)) {
756                         PyErr_SetString(PyExc_AttributeError,
757                                         "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS));
758                         return NULL;
759                 }
760         }
761         else if (PySequence_Check(length_ob)) {
762                 ndimensions = PySequence_Size(length_ob);
763                 if (ndimensions > MAX_DIMENSIONS) {
764                         PyErr_SetString(PyExc_AttributeError,
765                                         "too many dimensions, max is "STRINGIFY(MAX_DIMENSIONS));
766                         return NULL;
767                 }
768                 else if (ndimensions < 1) {
769                         PyErr_SetString(PyExc_AttributeError,
770                                         "sequence must have at least one dimension");
771                         return NULL;
772                 }
773                 for (i = 0; i < ndimensions; i++) {
774                         PyObject *ob = PySequence_GetItem(length_ob, i);
775
776                         if (!PyLong_Check(ob))
777                                 dimensions[i] = 1;
778                         else
779                                 dimensions[i] = PyLong_AsLong(ob);
780                         Py_DECREF(ob);
781
782                         if (dimensions[i] < 1) {
783                                 PyErr_SetString(PyExc_AttributeError,
784                                                 "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS));
785                                 return NULL;
786                         }
787                 }
788         }
789         else {
790                 PyErr_Format(PyExc_TypeError,
791                              "invalid second argument argument expected a sequence "
792                              "or an int, not a %.200s", Py_TYPE(length_ob)->tp_name);
793                 return NULL;
794         }
795
796         if (init && PyObject_CheckBuffer(init)) {
797                 Py_buffer pybuffer;
798
799                 if (PyObject_GetBuffer(init, &pybuffer, PyBUF_ND | PyBUF_FORMAT) == -1) {
800                         /* PyObject_GetBuffer raise a PyExc_BufferError */
801                         return NULL;
802                 }
803
804                 if (type != gl_buffer_type_from_py_format_char(pybuffer.format)) {
805                         PyErr_Format(PyExc_TypeError,
806                                      "`GL_TYPE` and `typestr` of object with buffer interface do not match. '%s'", pybuffer.format);
807                 }
808                 else if (ndimensions != pybuffer.ndim ||
809                         !compare_dimensions(ndimensions, dimensions, pybuffer.shape))
810                 {
811                         PyErr_Format(PyExc_TypeError, "array size does not match");
812                 }
813                 else {
814                         buffer = BGL_MakeBuffer_FromData(init, type, pybuffer.ndim, dimensions, pybuffer.buf);
815                 }
816
817                 PyBuffer_Release(&pybuffer);
818         }
819         else {
820                 buffer = BGL_MakeBuffer(type, ndimensions, dimensions, NULL);
821                 if (init && Buffer_ass_slice(buffer, 0, dimensions[0], init)) {
822                         Py_DECREF(buffer);
823                         return NULL;
824                 }
825         }
826
827         return (PyObject *)buffer;
828 }
829
830 /* Buffer sequence methods */
831
832 static int Buffer_len(Buffer *self)
833 {
834         return self->dimensions[0];
835 }
836
837 static PyObject *Buffer_item(Buffer *self, int i)
838 {
839         if (i >= self->dimensions[0] || i < 0) {
840                 PyErr_SetString(PyExc_IndexError, "array index out of range");
841                 return NULL;
842         }
843
844         if (self->ndimensions == 1) {
845                 switch (self->type) {
846                         case GL_BYTE:   return Py_BuildValue("b", self->buf.asbyte[i]);
847                         case GL_SHORT:  return Py_BuildValue("h", self->buf.asshort[i]);
848                         case GL_INT:    return Py_BuildValue("i", self->buf.asint[i]);
849                         case GL_FLOAT:  return PyFloat_FromDouble(self->buf.asfloat[i]);
850                         case GL_DOUBLE: return Py_BuildValue("d", self->buf.asdouble[i]);
851                 }
852         }
853         else {
854                 int j, offset = i * BGL_typeSize(self->type);
855
856                 for (j = 1; j < self->ndimensions; j++) {
857                         offset *= self->dimensions[j];
858                 }
859
860                 return (PyObject *)BGL_MakeBuffer_FromData(
861                         (PyObject *)self, self->type,
862                         self->ndimensions - 1,
863                         self->dimensions + 1,
864                         self->buf.asbyte + offset);
865         }
866
867         return NULL;
868 }
869
870 static PyObject *Buffer_slice(Buffer *self, int begin, int end)
871 {
872         PyObject *list;
873         int count;
874         
875         if (begin < 0) begin = 0;
876         if (end > self->dimensions[0]) end = self->dimensions[0];
877         if (begin > end) begin = end;
878
879         list = PyList_New(end - begin);
880
881         for (count = begin; count < end; count++) {
882                 PyList_SET_ITEM(list, count - begin, Buffer_item(self, count));
883         }
884         return list;
885 }
886
887 static int Buffer_ass_item(Buffer *self, int i, PyObject *v)
888 {
889         if (i >= self->dimensions[0] || i < 0) {
890                 PyErr_SetString(PyExc_IndexError,
891                                 "array assignment index out of range");
892                 return -1;
893         }
894
895         if (self->ndimensions != 1) {
896                 Buffer *row = (Buffer *)Buffer_item(self, i);
897
898                 if (row) {
899                         int ret = Buffer_ass_slice(row, 0, self->dimensions[1], v);
900                         Py_DECREF(row);
901                         return ret;
902                 }
903                 else {
904                         return -1;
905                 }
906         }
907
908         switch (self->type) {
909                 case GL_BYTE:   return PyArg_Parse(v, "b:Expected ints",   &self->buf.asbyte[i])   ? 0 : -1;
910                 case GL_SHORT:  return PyArg_Parse(v, "h:Expected ints",   &self->buf.asshort[i])  ? 0 : -1;
911                 case GL_INT:    return PyArg_Parse(v, "i:Expected ints",   &self->buf.asint[i])    ? 0 : -1;
912                 case GL_FLOAT:  return PyArg_Parse(v, "f:Expected floats", &self->buf.asfloat[i])  ? 0 : -1;
913                 case GL_DOUBLE: return PyArg_Parse(v, "d:Expected floats", &self->buf.asdouble[i]) ? 0 : -1;
914                 default:        return 0; /* should never happen */
915         }
916 }
917
918 static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq)
919 {
920         PyObject *item;
921         int count, err = 0;
922         
923         if (begin < 0) begin = 0;
924         if (end > self->dimensions[0]) end = self->dimensions[0];
925         if (begin > end) begin = end;
926         
927         if (!PySequence_Check(seq)) {
928                 PyErr_Format(PyExc_TypeError,
929                              "buffer[:] = value, invalid assignment. "
930                              "Expected a sequence, not an %.200s type",
931                              Py_TYPE(seq)->tp_name);
932                 return -1;
933         }
934
935         /* re-use count var */
936         if ((count = PySequence_Size(seq)) != (end - begin)) {
937                 PyErr_Format(PyExc_TypeError,
938                              "buffer[:] = value, size mismatch in assignment. "
939                              "Expected: %d (given: %d)", count, end - begin);
940                 return -1;
941         }
942         
943         for (count = begin; count < end; count++) {
944                 item = PySequence_GetItem(seq, count - begin);
945                 if (item) {
946                         err = Buffer_ass_item(self, count, item);
947                         Py_DECREF(item);
948                 }
949                 else {
950                         err = -1;
951                 }
952                 if (err) {
953                         break;
954                 }
955         }
956         return err;
957 }
958
959 static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
960 {
961         if (PyIndex_Check(item)) {
962                 Py_ssize_t i;
963                 i = PyNumber_AsSsize_t(item, PyExc_IndexError);
964                 if (i == -1 && PyErr_Occurred())
965                         return NULL;
966                 if (i < 0)
967                         i += self->dimensions[0];
968                 return Buffer_item(self, i);
969         }
970         else if (PySlice_Check(item)) {
971                 Py_ssize_t start, stop, step, slicelength;
972
973                 if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
974                         return NULL;
975
976                 if (slicelength <= 0) {
977                         return PyTuple_New(0);
978                 }
979                 else if (step == 1) {
980                         return Buffer_slice(self, start, stop);
981                 }
982                 else {
983                         PyErr_SetString(PyExc_IndexError,
984                                         "slice steps not supported with vectors");
985                         return NULL;
986                 }
987         }
988         else {
989                 PyErr_Format(PyExc_TypeError,
990                              "buffer indices must be integers, not %.200s",
991                              Py_TYPE(item)->tp_name);
992                 return NULL;
993         }
994 }
995
996 static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
997 {
998         if (PyIndex_Check(item)) {
999                 Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
1000                 if (i == -1 && PyErr_Occurred())
1001                         return -1;
1002                 if (i < 0)
1003                         i += self->dimensions[0];
1004                 return Buffer_ass_item(self, i, value);
1005         }
1006         else if (PySlice_Check(item)) {
1007                 Py_ssize_t start, stop, step, slicelength;
1008
1009                 if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
1010                         return -1;
1011
1012                 if (step == 1)
1013                         return Buffer_ass_slice(self, start, stop, value);
1014                 else {
1015                         PyErr_SetString(PyExc_IndexError,
1016                                         "slice steps not supported with vectors");
1017                         return -1;
1018                 }
1019         }
1020         else {
1021                 PyErr_Format(PyExc_TypeError,
1022                              "buffer indices must be integers, not %.200s",
1023                              Py_TYPE(item)->tp_name);
1024                 return -1;
1025         }
1026 }
1027
1028
1029 static void Buffer_dealloc(Buffer *self)
1030 {
1031         if (self->parent) {
1032                 Py_DECREF(self->parent);
1033         }
1034         else {
1035                 MEM_freeN(self->buf.asvoid);
1036         }
1037
1038         MEM_freeN(self->dimensions);
1039
1040         PyObject_DEL(self);
1041 }
1042
1043
1044 static PyObject *Buffer_repr(Buffer *self)
1045 {
1046         PyObject *list = Buffer_to_list_recursive(self);
1047         PyObject *repr;
1048         const char *typestr;
1049
1050         switch (self->type) {
1051                 case GL_BYTE:   typestr = "GL_BYTE"; break;
1052                 case GL_SHORT:  typestr = "GL_SHORT"; break;
1053                 case GL_INT:    typestr = "GL_INT"; break;
1054                 case GL_FLOAT:  typestr = "GL_FLOAT"; break;
1055                 case GL_DOUBLE: typestr = "GL_DOUBLE"; break;
1056                 default:        typestr = "UNKNOWN"; break;
1057         }
1058
1059         repr = PyUnicode_FromFormat("Buffer(%s, %R)", typestr, list);
1060         Py_DECREF(list);
1061
1062         return repr;
1063 }
1064
1065 /** \} */
1066
1067
1068 /* -------------------------------------------------------------------- */
1069
1070 /** \name OpenGL API Wrapping
1071  * \{ */
1072
1073 #define BGL_Wrap(funcname, ret, arg_list)                                     \
1074 static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args)   \
1075 {                                                                             \
1076         arg_def arg_list;                                                         \
1077         ret_def_##ret;                                                            \
1078         if (!PyArg_ParseTuple(args, arg_str arg_list, arg_ref arg_list)) {        \
1079                 return NULL;                                                          \
1080         }                                                                         \
1081         ret_set_##ret gl##funcname (arg_var arg_list);                            \
1082         ret_ret_##ret;                                                            \
1083 }
1084
1085 /* GL_VERSION_1_0 */
1086 BGL_Wrap(BlendFunc,                 void,      (GLenum, GLenum))
1087 BGL_Wrap(Clear,                     void,      (GLbitfield))
1088 BGL_Wrap(ClearColor,                void,      (GLfloat, GLfloat, GLfloat, GLfloat))
1089 BGL_Wrap(ClearDepth,                void,      (GLdouble))
1090 BGL_Wrap(ClearStencil,              void,      (GLint))
1091 BGL_Wrap(ColorMask,                 void,      (GLboolean, GLboolean, GLboolean, GLboolean))
1092 BGL_Wrap(CullFace,                  void,      (GLenum))
1093 BGL_Wrap(DepthFunc,                 void,      (GLenum))
1094 BGL_Wrap(DepthMask,                 void,      (GLboolean))
1095 BGL_Wrap(DepthRange,                void,      (GLdouble, GLdouble))
1096 BGL_Wrap(Disable,                   void,      (GLenum))
1097 BGL_Wrap(DrawBuffer,                void,      (GLenum))
1098 BGL_Wrap(Enable,                    void,      (GLenum))
1099 BGL_Wrap(Finish,                    void,      (void))
1100 BGL_Wrap(Flush,                     void,      (void))
1101 BGL_Wrap(FrontFace,                 void,      (GLenum))
1102 BGL_Wrap(GetBooleanv,               void,      (GLenum, GLbooleanP))
1103 BGL_Wrap(GetDoublev,                void,      (GLenum, GLdoubleP))
1104 BGL_Wrap(GetError,                  GLenum,    (void))
1105 BGL_Wrap(GetFloatv,                 void,      (GLenum, GLfloatP))
1106 BGL_Wrap(GetIntegerv,               void,      (GLenum, GLintP))
1107 BGL_Wrap(GetString,                 GLstring,  (GLenum))
1108 BGL_Wrap(GetTexImage,               void,      (GLenum, GLint, GLenum, GLenum, GLvoidP))
1109 BGL_Wrap(GetTexLevelParameterfv,    void,      (GLenum, GLint, GLenum, GLfloatP))
1110 BGL_Wrap(GetTexLevelParameteriv,    void,      (GLenum, GLint, GLenum, GLintP))
1111 BGL_Wrap(GetTexParameterfv,         void,      (GLenum, GLenum, GLfloatP))
1112 BGL_Wrap(GetTexParameteriv,         void,      (GLenum, GLenum, GLintP))
1113 BGL_Wrap(Hint,                      void,      (GLenum, GLenum))
1114 BGL_Wrap(IsEnabled,                 GLboolean, (GLenum))
1115 BGL_Wrap(LineWidth,                 void,      (GLfloat))
1116 BGL_Wrap(LogicOp,                   void,      (GLenum))
1117 BGL_Wrap(PixelStoref,               void,      (GLenum, GLfloat))
1118 BGL_Wrap(PixelStorei,               void,      (GLenum, GLint))
1119 BGL_Wrap(PointSize,                 void,      (GLfloat))
1120 BGL_Wrap(PolygonMode,               void,      (GLenum, GLenum))
1121 BGL_Wrap(ReadBuffer,                void,      (GLenum))
1122 BGL_Wrap(ReadPixels,                void,      (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoidP))
1123 BGL_Wrap(Scissor,                   void,      (GLint, GLint, GLsizei, GLsizei))
1124 BGL_Wrap(StencilFunc,               void,      (GLenum, GLint, GLuint))
1125 BGL_Wrap(StencilMask,               void,      (GLuint))
1126 BGL_Wrap(StencilOp,                 void,      (GLenum, GLenum, GLenum))
1127 BGL_Wrap(TexImage1D,                void,      (GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, GLvoidP))
1128 BGL_Wrap(TexImage2D,                void,      (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoidP))
1129 BGL_Wrap(TexParameterf,             void,      (GLenum, GLenum, GLfloat))
1130 BGL_Wrap(TexParameterfv,            void,      (GLenum, GLenum, GLfloatP))
1131 BGL_Wrap(TexParameteri,             void,      (GLenum, GLenum, GLint))
1132 BGL_Wrap(TexParameteriv,            void,      (GLenum, GLenum, GLintP))
1133 BGL_Wrap(Viewport,                  void,      (GLint, GLint, GLsizei, GLsizei))
1134
1135
1136 /* GL_VERSION_1_1 */
1137 BGL_Wrap(BindTexture,               void,      (GLenum, GLuint))
1138 BGL_Wrap(CopyTexImage1D,            void,      (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))
1139 BGL_Wrap(CopyTexImage2D,            void,      (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))
1140 BGL_Wrap(CopyTexSubImage1D,         void,      (GLenum, GLint, GLint, GLint, GLint, GLsizei))
1141 BGL_Wrap(CopyTexSubImage2D,         void,      (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))
1142 BGL_Wrap(DeleteTextures,            void,      (GLsizei, GLuintP))
1143 BGL_Wrap(DrawArrays,                void,      (GLenum, GLint, GLsizei))
1144 BGL_Wrap(DrawElements,              void,      (GLenum, GLsizei, GLenum, GLvoidP))
1145 BGL_Wrap(GenTextures,               void,      (GLsizei, GLuintP))
1146 BGL_Wrap(IsTexture,                 GLboolean, (GLuint))
1147 BGL_Wrap(PolygonOffset,             void,      (GLfloat, GLfloat))
1148 BGL_Wrap(TexSubImage1D,             void,      (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, GLvoidP))
1149 BGL_Wrap(TexSubImage2D,             void,      (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoidP))
1150
1151
1152 /* GL_VERSION_1_2 */
1153 BGL_Wrap(CopyTexSubImage3D,         void,      (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))
1154 BGL_Wrap(DrawRangeElements,         void,      (GLenum, GLuint, GLuint, GLsizei, GLenum, GLvoidP))
1155 BGL_Wrap(TexImage3D,                void,      (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoidP))
1156 BGL_Wrap(TexSubImage3D,             void,      (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoidP))
1157
1158
1159 /* GL_VERSION_1_3 */
1160 BGL_Wrap(ActiveTexture,             void,      (GLenum))
1161 BGL_Wrap(CompressedTexImage1D,      void,      (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, GLvoidP))
1162 BGL_Wrap(CompressedTexImage2D,      void,      (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, GLvoidP))
1163 BGL_Wrap(CompressedTexImage3D,      void,      (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, GLvoidP))
1164 BGL_Wrap(CompressedTexSubImage1D,   void,      (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, GLvoidP))
1165 BGL_Wrap(CompressedTexSubImage2D,   void,      (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, GLvoidP))
1166 BGL_Wrap(CompressedTexSubImage3D,   void,      (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, GLvoidP))
1167 BGL_Wrap(GetCompressedTexImage,     void,      (GLenum, GLint, GLvoidP))
1168 BGL_Wrap(SampleCoverage,            void,      (GLfloat, GLboolean))
1169
1170
1171 /* GL_VERSION_1_4 */
1172 BGL_Wrap(BlendColor,                void,      (GLfloat, GLfloat, GLfloat, GLfloat))
1173 BGL_Wrap(BlendEquation,             void,      (GLenum))
1174
1175
1176 /* GL_VERSION_1_5 */
1177 BGL_Wrap(BeginQuery,                void,      (GLenum, GLuint))
1178 BGL_Wrap(BindBuffer,                void,      (GLenum, GLuint))
1179 BGL_Wrap(BufferData,                void,      (GLenum, GLsizeiptr, GLvoidP, GLenum))
1180 BGL_Wrap(BufferSubData,             void,      (GLenum, GLintptr, GLsizeiptr, GLvoidP))
1181 BGL_Wrap(DeleteBuffers,             void,      (GLsizei, GLuintP))
1182 BGL_Wrap(DeleteQueries,             void,      (GLsizei, GLuintP))
1183 BGL_Wrap(EndQuery,                  void,      (GLenum))
1184 BGL_Wrap(GenBuffers,                void,      (GLsizei, GLuintP))
1185 BGL_Wrap(GenQueries,                void,      (GLsizei, GLuintP))
1186 BGL_Wrap(GetBufferParameteriv,      void,      (GLenum, GLenum, GLintP))
1187 BGL_Wrap(GetBufferPointerv,         void,      (GLenum, GLenum, GLvoidP))
1188 BGL_Wrap(GetBufferSubData,          void,      (GLenum, GLintptr, GLsizeiptr, GLvoidP))
1189 BGL_Wrap(GetQueryObjectiv,          void,      (GLuint, GLenum, GLintP))
1190 BGL_Wrap(GetQueryObjectuiv,         void,      (GLuint, GLenum, GLuintP))
1191 BGL_Wrap(GetQueryiv,                void,      (GLenum, GLenum, GLintP))
1192 BGL_Wrap(IsBuffer,                  GLboolean, (GLuint))
1193 BGL_Wrap(IsQuery,                   GLboolean, (GLuint))
1194 BGL_Wrap(MapBuffer,                 void,      (GLenum, GLenum))
1195 BGL_Wrap(UnmapBuffer,               GLboolean, (GLenum))
1196
1197
1198 /* GL_VERSION_2_0 */
1199 BGL_Wrap(AttachShader,              void,      (GLuint, GLuint))
1200 BGL_Wrap(BindAttribLocation,        void,      (GLuint, GLuint, GLstring))
1201 BGL_Wrap(BlendEquationSeparate,     void,      (GLenum, GLenum))
1202 BGL_Wrap(CompileShader,             void,      (GLuint))
1203 BGL_Wrap(CreateProgram,             GLuint,    (void))
1204 BGL_Wrap(CreateShader,              GLuint,    (GLenum))
1205 BGL_Wrap(DeleteProgram,             void,      (GLuint))
1206 BGL_Wrap(DeleteShader,              void,      (GLuint))
1207 BGL_Wrap(DetachShader,              void,      (GLuint, GLuint))
1208 BGL_Wrap(DisableVertexAttribArray,  void,      (GLuint))
1209 BGL_Wrap(DrawBuffers,               void,      (GLsizei, GLenumP))
1210 BGL_Wrap(EnableVertexAttribArray,   void,      (GLuint))
1211 BGL_Wrap(GetActiveAttrib,           void,      (GLuint, GLuint, GLsizei, GLsizeiP, GLintP, GLenumP, GLcharP))
1212 BGL_Wrap(GetActiveUniform,          void,      (GLuint, GLuint, GLsizei, GLsizeiP, GLintP, GLenumP, GLcharP))
1213 BGL_Wrap(GetAttachedShaders,        void,      (GLuint, GLsizei, GLsizeiP, GLuintP))
1214 BGL_Wrap(GetAttribLocation,         GLint,     (GLuint, GLstring))
1215 BGL_Wrap(GetProgramInfoLog,         void,      (GLuint, GLsizei, GLsizeiP, GLcharP))
1216 BGL_Wrap(GetProgramiv,              void,      (GLuint, GLenum, GLintP))
1217 BGL_Wrap(GetShaderInfoLog,          void,      (GLuint, GLsizei, GLsizeiP, GLcharP))
1218 BGL_Wrap(GetShaderSource,           void,      (GLuint, GLsizei, GLsizeiP, GLcharP))
1219 BGL_Wrap(GetShaderiv,               void,      (GLuint, GLenum, GLintP))
1220 BGL_Wrap(GetUniformLocation,        GLint,     (GLuint, GLstring))
1221 BGL_Wrap(GetUniformfv,              void,      (GLuint, GLint, GLfloatP))
1222 BGL_Wrap(GetUniformiv,              void,      (GLuint, GLint, GLintP))
1223 BGL_Wrap(GetVertexAttribPointerv,   void,      (GLuint, GLenum, GLvoidP))
1224 BGL_Wrap(GetVertexAttribdv,         void,      (GLuint, GLenum, GLdoubleP))
1225 BGL_Wrap(GetVertexAttribfv,         void,      (GLuint, GLenum, GLfloatP))
1226 BGL_Wrap(GetVertexAttribiv,         void,      (GLuint, GLenum, GLintP))
1227 BGL_Wrap(IsProgram,                 GLboolean, (GLuint))
1228 BGL_Wrap(IsShader,                  GLboolean, (GLuint))
1229 BGL_Wrap(LinkProgram,               void,      (GLuint))
1230 BGL_Wrap(StencilFuncSeparate,       void,      (GLenum, GLenum, GLint, GLuint))
1231 BGL_Wrap(StencilMaskSeparate,       void,      (GLenum, GLuint))
1232 BGL_Wrap(StencilOpSeparate,         void,      (GLenum, GLenum, GLenum, GLenum))
1233 BGL_Wrap(Uniform1f,                 void,      (GLint, GLfloat))
1234 BGL_Wrap(Uniform1fv,                void,      (GLint, GLsizei, GLfloatP))
1235 BGL_Wrap(Uniform1i,                 void,      (GLint, GLint))
1236 BGL_Wrap(Uniform1iv,                void,      (GLint, GLsizei, GLintP))
1237 BGL_Wrap(Uniform2f,                 void,      (GLint, GLfloat, GLfloat))
1238 BGL_Wrap(Uniform2fv,                void,      (GLint, GLsizei, GLfloatP))
1239 BGL_Wrap(Uniform2i,                 void,      (GLint, GLint, GLint))
1240 BGL_Wrap(Uniform2iv,                void,      (GLint, GLsizei, GLintP))
1241 BGL_Wrap(Uniform3f,                 void,      (GLint, GLfloat, GLfloat, GLfloat))
1242 BGL_Wrap(Uniform3fv,                void,      (GLint, GLsizei, GLfloatP))
1243 BGL_Wrap(Uniform3i,                 void,      (GLint, GLint, GLint, GLint))
1244 BGL_Wrap(Uniform3iv,                void,      (GLint, GLsizei, GLintP))
1245 BGL_Wrap(Uniform4f,                 void,      (GLint, GLfloat, GLfloat, GLfloat, GLfloat))
1246 BGL_Wrap(Uniform4fv,                void,      (GLint, GLsizei, GLfloatP))
1247 BGL_Wrap(Uniform4i,                 void,      (GLint, GLint, GLint, GLint, GLint))
1248 BGL_Wrap(Uniform4iv,                void,      (GLint, GLsizei, GLintP))
1249 BGL_Wrap(UniformMatrix2fv,          void,      (GLint, GLsizei, GLboolean, GLfloatP))
1250 BGL_Wrap(UniformMatrix3fv,          void,      (GLint, GLsizei, GLboolean, GLfloatP))
1251 BGL_Wrap(UniformMatrix4fv,          void,      (GLint, GLsizei, GLboolean, GLfloatP))
1252 BGL_Wrap(UseProgram,                void,      (GLuint))
1253 BGL_Wrap(ValidateProgram,           void,      (GLuint))
1254 BGL_Wrap(VertexAttrib1d,            void,      (GLuint, GLdouble))
1255 BGL_Wrap(VertexAttrib1dv,           void,      (GLuint, GLdoubleP))
1256 BGL_Wrap(VertexAttrib1f,            void,      (GLuint, GLfloat))
1257 BGL_Wrap(VertexAttrib1fv,           void,      (GLuint, GLfloatP))
1258 BGL_Wrap(VertexAttrib1s,            void,      (GLuint, GLshort))
1259 BGL_Wrap(VertexAttrib1sv,           void,      (GLuint, GLshortP))
1260 BGL_Wrap(VertexAttrib2d,            void,      (GLuint, GLdouble, GLdouble))
1261 BGL_Wrap(VertexAttrib2dv,           void,      (GLuint, GLdoubleP))
1262 BGL_Wrap(VertexAttrib2f,            void,      (GLuint, GLfloat, GLfloat))
1263 BGL_Wrap(VertexAttrib2fv,           void,      (GLuint, GLfloatP))
1264 BGL_Wrap(VertexAttrib2s,            void,      (GLuint, GLshort, GLshort))
1265 BGL_Wrap(VertexAttrib2sv,           void,      (GLuint, GLshortP))
1266 BGL_Wrap(VertexAttrib3d,            void,      (GLuint, GLdouble, GLdouble, GLdouble))
1267 BGL_Wrap(VertexAttrib3dv,           void,      (GLuint, GLdoubleP))
1268 BGL_Wrap(VertexAttrib3f,            void,      (GLuint, GLfloat, GLfloat, GLfloat))
1269 BGL_Wrap(VertexAttrib3fv,           void,      (GLuint, GLfloatP))
1270 BGL_Wrap(VertexAttrib3s,            void,      (GLuint, GLshort, GLshort, GLshort))
1271 BGL_Wrap(VertexAttrib3sv,           void,      (GLuint, GLshortP))
1272 BGL_Wrap(VertexAttrib4Nbv,          void,      (GLuint, GLbyteP))
1273 BGL_Wrap(VertexAttrib4Niv,          void,      (GLuint, GLintP))
1274 BGL_Wrap(VertexAttrib4Nsv,          void,      (GLuint, GLshortP))
1275 BGL_Wrap(VertexAttrib4Nub,          void,      (GLuint, GLubyte, GLubyte, GLubyte, GLubyte))
1276 BGL_Wrap(VertexAttrib4Nubv,         void,      (GLuint, GLubyteP))
1277 BGL_Wrap(VertexAttrib4Nuiv,         void,      (GLuint, GLuintP))
1278 BGL_Wrap(VertexAttrib4Nusv,         void,      (GLuint, GLushortP))
1279 BGL_Wrap(VertexAttrib4bv,           void,      (GLuint, GLbyteP))
1280 BGL_Wrap(VertexAttrib4d,            void,      (GLuint, GLdouble, GLdouble, GLdouble, GLdouble))
1281 BGL_Wrap(VertexAttrib4dv,           void,      (GLuint, GLdoubleP))
1282 BGL_Wrap(VertexAttrib4f,            void,      (GLuint, GLfloat, GLfloat, GLfloat, GLfloat))
1283 BGL_Wrap(VertexAttrib4fv,           void,      (GLuint, GLfloatP))
1284 BGL_Wrap(VertexAttrib4iv,           void,      (GLuint, GLintP))
1285 BGL_Wrap(VertexAttrib4s,            void,      (GLuint, GLshort, GLshort, GLshort, GLshort))
1286 BGL_Wrap(VertexAttrib4sv,           void,      (GLuint, GLshortP))
1287 BGL_Wrap(VertexAttrib4ubv,          void,      (GLuint, GLubyteP))
1288 BGL_Wrap(VertexAttrib4uiv,          void,      (GLuint, GLuintP))
1289 BGL_Wrap(VertexAttrib4usv,          void,      (GLuint, GLushortP))
1290 BGL_Wrap(VertexAttribPointer,       void,      (GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoidP))
1291
1292
1293 /* GL_VERSION_2_1 */
1294 BGL_Wrap(UniformMatrix2x3fv,        void,      (GLint, GLsizei, GLboolean, GLfloatP))
1295 BGL_Wrap(UniformMatrix2x4fv,        void,      (GLint, GLsizei, GLboolean, GLfloatP))
1296 BGL_Wrap(UniformMatrix3x2fv,        void,      (GLint, GLsizei, GLboolean, GLfloatP))
1297 BGL_Wrap(UniformMatrix3x4fv,        void,      (GLint, GLsizei, GLboolean, GLfloatP))
1298 BGL_Wrap(UniformMatrix4x2fv,        void,      (GLint, GLsizei, GLboolean, GLfloatP))
1299 BGL_Wrap(UniformMatrix4x3fv,        void,      (GLint, GLsizei, GLboolean, GLfloatP))
1300
1301
1302 /* GL_VERSION_3_0 */
1303 BGL_Wrap(BindVertexArray,           void,      (GLuint))
1304 BGL_Wrap(DeleteVertexArrays,        void,      (GLsizei, GLuintP))
1305 BGL_Wrap(GenVertexArrays,           void,      (GLsizei, GLuintP))
1306 BGL_Wrap(IsVertexArray,             GLboolean, (GLuint))
1307
1308
1309 /* GL_VERSION_3_1 */
1310 BGL_Wrap(BindBufferBase,            void,      (GLenum, GLuint, GLuint))
1311 BGL_Wrap(BindBufferRange,           void,      (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr))
1312 BGL_Wrap(GetActiveUniformBlockName, void,      (GLuint, GLuint, GLsizei, GLsizeiP, GLcharP))
1313 BGL_Wrap(GetActiveUniformBlockiv,   void,      (GLuint, GLuint, GLenum, GLintP))
1314 BGL_Wrap(GetActiveUniformName,      void,      (GLuint, GLuint, GLsizei, GLsizeiP, GLcharP))
1315 BGL_Wrap(GetActiveUniformsiv,       void,      (GLuint, GLsizei, GLuintP, GLenum, GLintP))
1316 BGL_Wrap(GetIntegeri_v,             void,      (GLenum, GLuint, GLintP))
1317 BGL_Wrap(GetUniformBlockIndex,      GLuint,    (GLuint, GLstring))
1318 BGL_Wrap(GetUniformIndices,         void,      (GLuint, GLsizei, GLcharP, GLuintP))
1319 BGL_Wrap(UniformBlockBinding,       void,      (GLuint, GLuint, GLuint))
1320
1321
1322 /* GL_VERSION_3_2 */
1323 BGL_Wrap(FramebufferTexture,        void,      (GLenum, GLenum, GLuint, GLint))
1324 BGL_Wrap(GetBufferParameteri64v,    void,      (GLenum, GLenum, GLint64P))
1325 BGL_Wrap(GetInteger64i_v,           void,      (GLenum, GLuint, GLint64P))
1326 BGL_Wrap(GetMultisamplefv,          void,      (GLenum, GLuint, GLfloatP))
1327 BGL_Wrap(SampleMaski,               void,      (GLuint, GLbitfield))
1328 BGL_Wrap(TexImage2DMultisample,     void,      (GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLboolean))
1329 BGL_Wrap(TexImage3DMultisample,     void,      (GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, GLboolean))
1330
1331
1332 /* GL_VERSION_3_3 */
1333 /* no new functions besides packed immediate mode (not part of core profile) */
1334
1335 /** \} */
1336
1337
1338 /* -------------------------------------------------------------------- */
1339
1340 /** \name Module Definition
1341  * \{ */
1342
1343 static struct PyModuleDef BGL_module_def = {
1344         PyModuleDef_HEAD_INIT,
1345         "bgl",  /* m_name */
1346         NULL,  /* m_doc */
1347         0,  /* m_size */
1348         NULL,  /* m_methods */
1349         NULL,  /* m_reload */
1350         NULL,  /* m_traverse */
1351         NULL,  /* m_clear */
1352         NULL,  /* m_free */
1353 };
1354
1355 static void py_module_dict_add_int(PyObject *dict, const char *name, int value)
1356 {
1357         PyObject *item;
1358         PyDict_SetItemString(dict, name, item = PyLong_FromLong(value));
1359         Py_DECREF(item);
1360 }
1361
1362 static void py_module_dict_add_int64(PyObject *dict, const char *name, int64_t value)
1363 {
1364         PyObject *item;
1365         PyDict_SetItemString(dict, name, item = PyLong_FromLongLong(value));
1366         Py_DECREF(item);
1367 }
1368
1369 static void py_module_dict_add_method(PyObject *submodule, PyObject *dict, PyMethodDef *method_def, bool is_valid)
1370 {
1371         if (is_valid) {
1372                 PyObject *m;
1373                 m = PyCFunction_NewEx(method_def, NULL, submodule);
1374                 PyDict_SetItemString(dict, method_def->ml_name, m);
1375                 Py_DECREF(m);
1376         }
1377         else {
1378                 PyDict_SetItemString(dict, method_def->ml_name, Py_None);
1379         }
1380 }
1381
1382 PyObject *BPyInit_bgl(void)
1383 {
1384         PyObject *submodule, *dict;
1385         submodule = PyModule_Create(&BGL_module_def);
1386         dict = PyModule_GetDict(submodule);
1387
1388         if (PyType_Ready(&BGL_bufferType) < 0)
1389                 return NULL;  /* should never happen */
1390
1391         PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType);
1392         Py_INCREF((PyObject *)&BGL_bufferType);
1393
1394 /* needed since some function pointers won't be NULL */
1395 #ifdef __GNUC__
1396 #  pragma GCC diagnostic ignored "-Waddress"
1397 #endif
1398
1399 #define PY_MOD_ADD_METHOD(func) \
1400         { \
1401                 static PyMethodDef method_def = {"gl"#func, Method_##func, METH_VARARGS}; \
1402                 py_module_dict_add_method(submodule, dict, &method_def, (gl##func != NULL)); \
1403         } ((void)0)
1404
1405         /* GL_VERSION_1_0 */
1406         {
1407                 PY_MOD_ADD_METHOD(BlendFunc);
1408                 PY_MOD_ADD_METHOD(Clear);
1409                 PY_MOD_ADD_METHOD(ClearColor);
1410                 PY_MOD_ADD_METHOD(ClearDepth);
1411                 PY_MOD_ADD_METHOD(ClearStencil);
1412                 PY_MOD_ADD_METHOD(ColorMask);
1413                 PY_MOD_ADD_METHOD(CullFace);
1414                 PY_MOD_ADD_METHOD(DepthFunc);
1415                 PY_MOD_ADD_METHOD(DepthMask);
1416                 PY_MOD_ADD_METHOD(DepthRange);
1417                 PY_MOD_ADD_METHOD(Disable);
1418                 PY_MOD_ADD_METHOD(DrawBuffer);
1419                 PY_MOD_ADD_METHOD(Enable);
1420                 PY_MOD_ADD_METHOD(Finish);
1421                 PY_MOD_ADD_METHOD(Flush);
1422                 PY_MOD_ADD_METHOD(FrontFace);
1423                 PY_MOD_ADD_METHOD(GetBooleanv);
1424                 PY_MOD_ADD_METHOD(GetDoublev);
1425                 PY_MOD_ADD_METHOD(GetError);
1426                 PY_MOD_ADD_METHOD(GetFloatv);
1427                 PY_MOD_ADD_METHOD(GetIntegerv);
1428                 PY_MOD_ADD_METHOD(GetString);
1429                 PY_MOD_ADD_METHOD(GetTexImage);
1430                 PY_MOD_ADD_METHOD(GetTexLevelParameterfv);
1431                 PY_MOD_ADD_METHOD(GetTexLevelParameteriv);
1432                 PY_MOD_ADD_METHOD(GetTexParameterfv);
1433                 PY_MOD_ADD_METHOD(GetTexParameteriv);
1434                 PY_MOD_ADD_METHOD(Hint);
1435                 PY_MOD_ADD_METHOD(IsEnabled);
1436                 PY_MOD_ADD_METHOD(LineWidth);
1437                 PY_MOD_ADD_METHOD(LogicOp);
1438                 PY_MOD_ADD_METHOD(PixelStoref);
1439                 PY_MOD_ADD_METHOD(PixelStorei);
1440                 PY_MOD_ADD_METHOD(PointSize);
1441                 PY_MOD_ADD_METHOD(PolygonMode);
1442                 PY_MOD_ADD_METHOD(ReadBuffer);
1443                 PY_MOD_ADD_METHOD(ReadPixels);
1444                 PY_MOD_ADD_METHOD(Scissor);
1445                 PY_MOD_ADD_METHOD(StencilFunc);
1446                 PY_MOD_ADD_METHOD(StencilMask);
1447                 PY_MOD_ADD_METHOD(StencilOp);
1448                 PY_MOD_ADD_METHOD(TexImage1D);
1449                 PY_MOD_ADD_METHOD(TexImage2D);
1450                 PY_MOD_ADD_METHOD(TexParameterf);
1451                 PY_MOD_ADD_METHOD(TexParameterfv);
1452                 PY_MOD_ADD_METHOD(TexParameteri);
1453                 PY_MOD_ADD_METHOD(TexParameteriv);
1454                 PY_MOD_ADD_METHOD(Viewport);
1455         }
1456
1457         /* GL_VERSION_1_1 */
1458         {
1459                 PY_MOD_ADD_METHOD(BindTexture);
1460                 PY_MOD_ADD_METHOD(CopyTexImage1D);
1461                 PY_MOD_ADD_METHOD(CopyTexImage2D);
1462                 PY_MOD_ADD_METHOD(CopyTexSubImage1D);
1463                 PY_MOD_ADD_METHOD(CopyTexSubImage2D);
1464                 PY_MOD_ADD_METHOD(DeleteTextures);
1465                 PY_MOD_ADD_METHOD(DrawArrays);
1466                 PY_MOD_ADD_METHOD(DrawElements);
1467                 PY_MOD_ADD_METHOD(GenTextures);
1468                 PY_MOD_ADD_METHOD(IsTexture);
1469                 PY_MOD_ADD_METHOD(PolygonOffset);
1470                 PY_MOD_ADD_METHOD(TexSubImage1D);
1471                 PY_MOD_ADD_METHOD(TexSubImage2D);
1472         }
1473
1474         /* GL_VERSION_1_2 */
1475         {
1476                 PY_MOD_ADD_METHOD(CopyTexSubImage3D);
1477                 PY_MOD_ADD_METHOD(DrawRangeElements);
1478                 PY_MOD_ADD_METHOD(TexImage3D);
1479                 PY_MOD_ADD_METHOD(TexSubImage3D);
1480         }
1481
1482         /* GL_VERSION_1_3 */
1483         {
1484                 PY_MOD_ADD_METHOD(ActiveTexture);
1485                 PY_MOD_ADD_METHOD(CompressedTexImage1D);
1486                 PY_MOD_ADD_METHOD(CompressedTexImage2D);
1487                 PY_MOD_ADD_METHOD(CompressedTexImage3D);
1488                 PY_MOD_ADD_METHOD(CompressedTexSubImage1D);
1489                 PY_MOD_ADD_METHOD(CompressedTexSubImage2D);
1490                 PY_MOD_ADD_METHOD(CompressedTexSubImage3D);
1491                 PY_MOD_ADD_METHOD(GetCompressedTexImage);
1492                 PY_MOD_ADD_METHOD(SampleCoverage);
1493         }
1494
1495         /* GL_VERSION_1_4 */
1496         {
1497                 PY_MOD_ADD_METHOD(BlendColor);
1498                 PY_MOD_ADD_METHOD(BlendEquation);
1499         }
1500
1501         /* GL_VERSION_1_5 */
1502         {
1503                 PY_MOD_ADD_METHOD(BeginQuery);
1504                 PY_MOD_ADD_METHOD(BindBuffer);
1505                 PY_MOD_ADD_METHOD(BufferData);
1506                 PY_MOD_ADD_METHOD(BufferSubData);
1507                 PY_MOD_ADD_METHOD(DeleteBuffers);
1508                 PY_MOD_ADD_METHOD(DeleteQueries);
1509                 PY_MOD_ADD_METHOD(EndQuery);
1510                 PY_MOD_ADD_METHOD(GenBuffers);
1511                 PY_MOD_ADD_METHOD(GenQueries);
1512                 PY_MOD_ADD_METHOD(GetBufferParameteriv);
1513                 PY_MOD_ADD_METHOD(GetBufferPointerv);
1514                 PY_MOD_ADD_METHOD(GetBufferSubData);
1515                 PY_MOD_ADD_METHOD(GetQueryObjectiv);
1516                 PY_MOD_ADD_METHOD(GetQueryObjectuiv);
1517                 PY_MOD_ADD_METHOD(GetQueryiv);
1518                 PY_MOD_ADD_METHOD(IsBuffer);
1519                 PY_MOD_ADD_METHOD(IsQuery);
1520                 PY_MOD_ADD_METHOD(MapBuffer);
1521                 PY_MOD_ADD_METHOD(UnmapBuffer);
1522         }
1523
1524         /* GL_VERSION_2_0 */
1525         {
1526                 PY_MOD_ADD_METHOD(AttachShader);
1527                 PY_MOD_ADD_METHOD(BindAttribLocation);
1528                 PY_MOD_ADD_METHOD(BlendEquationSeparate);
1529                 PY_MOD_ADD_METHOD(CompileShader);
1530                 PY_MOD_ADD_METHOD(CreateProgram);
1531                 PY_MOD_ADD_METHOD(CreateShader);
1532                 PY_MOD_ADD_METHOD(DeleteProgram);
1533                 PY_MOD_ADD_METHOD(DeleteShader);
1534                 PY_MOD_ADD_METHOD(DetachShader);
1535                 PY_MOD_ADD_METHOD(DisableVertexAttribArray);
1536                 PY_MOD_ADD_METHOD(DrawBuffers);
1537                 PY_MOD_ADD_METHOD(EnableVertexAttribArray);
1538                 PY_MOD_ADD_METHOD(GetActiveAttrib);
1539                 PY_MOD_ADD_METHOD(GetActiveUniform);
1540                 PY_MOD_ADD_METHOD(GetAttachedShaders);
1541                 PY_MOD_ADD_METHOD(GetAttribLocation);
1542                 PY_MOD_ADD_METHOD(GetProgramInfoLog);
1543                 PY_MOD_ADD_METHOD(GetProgramiv);
1544                 PY_MOD_ADD_METHOD(GetShaderInfoLog);
1545                 PY_MOD_ADD_METHOD(GetShaderSource);
1546                 PY_MOD_ADD_METHOD(GetShaderiv);
1547                 PY_MOD_ADD_METHOD(GetUniformLocation);
1548                 PY_MOD_ADD_METHOD(GetUniformfv);
1549                 PY_MOD_ADD_METHOD(GetUniformiv);
1550                 PY_MOD_ADD_METHOD(GetVertexAttribPointerv);
1551                 PY_MOD_ADD_METHOD(GetVertexAttribdv);
1552                 PY_MOD_ADD_METHOD(GetVertexAttribfv);
1553                 PY_MOD_ADD_METHOD(GetVertexAttribiv);
1554                 PY_MOD_ADD_METHOD(IsProgram);
1555                 PY_MOD_ADD_METHOD(IsShader);
1556                 PY_MOD_ADD_METHOD(LinkProgram);
1557                 PY_MOD_ADD_METHOD(ShaderSource);
1558                 PY_MOD_ADD_METHOD(StencilFuncSeparate);
1559                 PY_MOD_ADD_METHOD(StencilMaskSeparate);
1560                 PY_MOD_ADD_METHOD(StencilOpSeparate);
1561                 PY_MOD_ADD_METHOD(Uniform1f);
1562                 PY_MOD_ADD_METHOD(Uniform1fv);
1563                 PY_MOD_ADD_METHOD(Uniform1i);
1564                 PY_MOD_ADD_METHOD(Uniform1iv);
1565                 PY_MOD_ADD_METHOD(Uniform2f);
1566                 PY_MOD_ADD_METHOD(Uniform2fv);
1567                 PY_MOD_ADD_METHOD(Uniform2i);
1568                 PY_MOD_ADD_METHOD(Uniform2iv);
1569                 PY_MOD_ADD_METHOD(Uniform3f);
1570                 PY_MOD_ADD_METHOD(Uniform3fv);
1571                 PY_MOD_ADD_METHOD(Uniform3i);
1572                 PY_MOD_ADD_METHOD(Uniform3iv);
1573                 PY_MOD_ADD_METHOD(Uniform4f);
1574                 PY_MOD_ADD_METHOD(Uniform4fv);
1575                 PY_MOD_ADD_METHOD(Uniform4i);
1576                 PY_MOD_ADD_METHOD(Uniform4iv);
1577                 PY_MOD_ADD_METHOD(UniformMatrix2fv);
1578                 PY_MOD_ADD_METHOD(UniformMatrix3fv);
1579                 PY_MOD_ADD_METHOD(UniformMatrix4fv);
1580                 PY_MOD_ADD_METHOD(UseProgram);
1581                 PY_MOD_ADD_METHOD(ValidateProgram);
1582                 PY_MOD_ADD_METHOD(VertexAttrib1d);
1583                 PY_MOD_ADD_METHOD(VertexAttrib1dv);
1584                 PY_MOD_ADD_METHOD(VertexAttrib1f);
1585                 PY_MOD_ADD_METHOD(VertexAttrib1fv);
1586                 PY_MOD_ADD_METHOD(VertexAttrib1s);
1587                 PY_MOD_ADD_METHOD(VertexAttrib1sv);
1588                 PY_MOD_ADD_METHOD(VertexAttrib2d);
1589                 PY_MOD_ADD_METHOD(VertexAttrib2dv);
1590                 PY_MOD_ADD_METHOD(VertexAttrib2f);
1591                 PY_MOD_ADD_METHOD(VertexAttrib2fv);
1592                 PY_MOD_ADD_METHOD(VertexAttrib2s);
1593                 PY_MOD_ADD_METHOD(VertexAttrib2sv);
1594                 PY_MOD_ADD_METHOD(VertexAttrib3d);
1595                 PY_MOD_ADD_METHOD(VertexAttrib3dv);
1596                 PY_MOD_ADD_METHOD(VertexAttrib3f);
1597                 PY_MOD_ADD_METHOD(VertexAttrib3fv);
1598                 PY_MOD_ADD_METHOD(VertexAttrib3s);
1599                 PY_MOD_ADD_METHOD(VertexAttrib3sv);
1600                 PY_MOD_ADD_METHOD(VertexAttrib4Nbv);
1601                 PY_MOD_ADD_METHOD(VertexAttrib4Niv);
1602                 PY_MOD_ADD_METHOD(VertexAttrib4Nsv);
1603                 PY_MOD_ADD_METHOD(VertexAttrib4Nub);
1604                 PY_MOD_ADD_METHOD(VertexAttrib4Nubv);
1605                 PY_MOD_ADD_METHOD(VertexAttrib4Nuiv);
1606                 PY_MOD_ADD_METHOD(VertexAttrib4Nusv);
1607                 PY_MOD_ADD_METHOD(VertexAttrib4bv);
1608                 PY_MOD_ADD_METHOD(VertexAttrib4d);
1609                 PY_MOD_ADD_METHOD(VertexAttrib4dv);
1610                 PY_MOD_ADD_METHOD(VertexAttrib4f);
1611                 PY_MOD_ADD_METHOD(VertexAttrib4fv);
1612                 PY_MOD_ADD_METHOD(VertexAttrib4iv);
1613                 PY_MOD_ADD_METHOD(VertexAttrib4s);
1614                 PY_MOD_ADD_METHOD(VertexAttrib4sv);
1615                 PY_MOD_ADD_METHOD(VertexAttrib4ubv);
1616                 PY_MOD_ADD_METHOD(VertexAttrib4uiv);
1617                 PY_MOD_ADD_METHOD(VertexAttrib4usv);
1618                 PY_MOD_ADD_METHOD(VertexAttribPointer);
1619         }
1620
1621         /* GL_VERSION_2_1 */
1622         {
1623                 PY_MOD_ADD_METHOD(UniformMatrix2x3fv);
1624                 PY_MOD_ADD_METHOD(UniformMatrix2x4fv);
1625                 PY_MOD_ADD_METHOD(UniformMatrix3x2fv);
1626                 PY_MOD_ADD_METHOD(UniformMatrix3x4fv);
1627                 PY_MOD_ADD_METHOD(UniformMatrix4x2fv);
1628                 PY_MOD_ADD_METHOD(UniformMatrix4x3fv);
1629         }
1630
1631         /* GL_VERSION_3_0 */
1632         {
1633                 PY_MOD_ADD_METHOD(BindVertexArray);
1634                 PY_MOD_ADD_METHOD(DeleteVertexArrays);
1635                 PY_MOD_ADD_METHOD(GenVertexArrays);
1636                 PY_MOD_ADD_METHOD(IsVertexArray);
1637         }
1638
1639         /* GL_VERSION_3_1 */
1640         {
1641                 PY_MOD_ADD_METHOD(BindBufferBase);
1642                 PY_MOD_ADD_METHOD(BindBufferRange);
1643                 PY_MOD_ADD_METHOD(GetActiveUniformBlockName);
1644                 PY_MOD_ADD_METHOD(GetActiveUniformBlockiv);
1645                 PY_MOD_ADD_METHOD(GetActiveUniformName);
1646                 PY_MOD_ADD_METHOD(GetActiveUniformsiv);
1647                 PY_MOD_ADD_METHOD(GetIntegeri_v);
1648                 PY_MOD_ADD_METHOD(GetUniformBlockIndex);
1649                 PY_MOD_ADD_METHOD(GetUniformIndices);
1650                 PY_MOD_ADD_METHOD(UniformBlockBinding);
1651         }
1652
1653         /* GL_VERSION_3_2 */
1654         {
1655                 PY_MOD_ADD_METHOD(FramebufferTexture);
1656                 PY_MOD_ADD_METHOD(GetBufferParameteri64v);
1657                 PY_MOD_ADD_METHOD(GetInteger64i_v);
1658                 PY_MOD_ADD_METHOD(GetMultisamplefv);
1659                 PY_MOD_ADD_METHOD(SampleMaski);
1660                 PY_MOD_ADD_METHOD(TexImage2DMultisample);
1661                 PY_MOD_ADD_METHOD(TexImage3DMultisample);
1662         }
1663
1664         /* GL_VERSION_3_3 */
1665         {
1666         }
1667
1668 #define PY_DICT_ADD_INT(x) py_module_dict_add_int(dict, #x, x)
1669 #define PY_DICT_ADD_INT64(x) py_module_dict_add_int64(dict, #x, x)
1670
1671         /* GL_VERSION_1_1 */
1672         {
1673                 PY_DICT_ADD_INT(GL_ALPHA);
1674                 PY_DICT_ADD_INT(GL_ALWAYS);
1675                 PY_DICT_ADD_INT(GL_AND);
1676                 PY_DICT_ADD_INT(GL_AND_INVERTED);
1677                 PY_DICT_ADD_INT(GL_AND_REVERSE);
1678                 PY_DICT_ADD_INT(GL_BACK);
1679                 PY_DICT_ADD_INT(GL_BACK_LEFT);
1680                 PY_DICT_ADD_INT(GL_BACK_RIGHT);
1681                 PY_DICT_ADD_INT(GL_BLEND);
1682                 PY_DICT_ADD_INT(GL_BLEND_DST);
1683                 PY_DICT_ADD_INT(GL_BLEND_SRC);
1684                 PY_DICT_ADD_INT(GL_BLUE);
1685                 PY_DICT_ADD_INT(GL_BYTE);
1686                 PY_DICT_ADD_INT(GL_CCW);
1687                 PY_DICT_ADD_INT(GL_CLEAR);
1688                 PY_DICT_ADD_INT(GL_COLOR);
1689                 PY_DICT_ADD_INT(GL_COLOR_BUFFER_BIT);
1690                 PY_DICT_ADD_INT(GL_COLOR_CLEAR_VALUE);
1691                 PY_DICT_ADD_INT(GL_COLOR_LOGIC_OP);
1692                 PY_DICT_ADD_INT(GL_COLOR_WRITEMASK);
1693                 PY_DICT_ADD_INT(GL_COPY);
1694                 PY_DICT_ADD_INT(GL_COPY_INVERTED);
1695                 PY_DICT_ADD_INT(GL_CULL_FACE);
1696                 PY_DICT_ADD_INT(GL_CULL_FACE_MODE);
1697                 PY_DICT_ADD_INT(GL_CW);
1698                 PY_DICT_ADD_INT(GL_DECR);
1699                 PY_DICT_ADD_INT(GL_DEPTH);
1700                 PY_DICT_ADD_INT(GL_DEPTH_BUFFER_BIT);
1701                 PY_DICT_ADD_INT(GL_DEPTH_CLEAR_VALUE);
1702                 PY_DICT_ADD_INT(GL_DEPTH_COMPONENT);
1703                 PY_DICT_ADD_INT(GL_DEPTH_FUNC);
1704                 PY_DICT_ADD_INT(GL_DEPTH_RANGE);
1705                 PY_DICT_ADD_INT(GL_DEPTH_TEST);
1706                 PY_DICT_ADD_INT(GL_DEPTH_WRITEMASK);
1707                 PY_DICT_ADD_INT(GL_DITHER);
1708                 PY_DICT_ADD_INT(GL_DONT_CARE);
1709                 PY_DICT_ADD_INT(GL_DOUBLE);
1710                 PY_DICT_ADD_INT(GL_DOUBLEBUFFER);
1711                 PY_DICT_ADD_INT(GL_DRAW_BUFFER);
1712                 PY_DICT_ADD_INT(GL_DST_ALPHA);
1713                 PY_DICT_ADD_INT(GL_DST_COLOR);
1714                 PY_DICT_ADD_INT(GL_EQUAL);
1715                 PY_DICT_ADD_INT(GL_EQUIV);
1716                 PY_DICT_ADD_INT(GL_EXTENSIONS);
1717                 PY_DICT_ADD_INT(GL_FALSE);
1718                 PY_DICT_ADD_INT(GL_FASTEST);
1719                 PY_DICT_ADD_INT(GL_FILL);
1720                 PY_DICT_ADD_INT(GL_FLOAT);
1721                 PY_DICT_ADD_INT(GL_FRONT);
1722                 PY_DICT_ADD_INT(GL_FRONT_AND_BACK);
1723                 PY_DICT_ADD_INT(GL_FRONT_FACE);
1724                 PY_DICT_ADD_INT(GL_FRONT_LEFT);
1725                 PY_DICT_ADD_INT(GL_FRONT_RIGHT);
1726                 PY_DICT_ADD_INT(GL_GEQUAL);
1727                 PY_DICT_ADD_INT(GL_GREATER);
1728                 PY_DICT_ADD_INT(GL_GREEN);
1729                 PY_DICT_ADD_INT(GL_INCR);
1730                 PY_DICT_ADD_INT(GL_INT);
1731                 PY_DICT_ADD_INT(GL_INVALID_ENUM);
1732                 PY_DICT_ADD_INT(GL_INVALID_OPERATION);
1733                 PY_DICT_ADD_INT(GL_INVALID_VALUE);
1734                 PY_DICT_ADD_INT(GL_INVERT);
1735                 PY_DICT_ADD_INT(GL_KEEP);
1736                 PY_DICT_ADD_INT(GL_LEFT);
1737                 PY_DICT_ADD_INT(GL_LEQUAL);
1738                 PY_DICT_ADD_INT(GL_LESS);
1739                 PY_DICT_ADD_INT(GL_LINE);
1740                 PY_DICT_ADD_INT(GL_LINEAR);
1741                 PY_DICT_ADD_INT(GL_LINEAR_MIPMAP_LINEAR);
1742                 PY_DICT_ADD_INT(GL_LINEAR_MIPMAP_NEAREST);
1743                 PY_DICT_ADD_INT(GL_LINES);
1744                 PY_DICT_ADD_INT(GL_LINE_LOOP);
1745                 PY_DICT_ADD_INT(GL_LINE_SMOOTH);
1746                 PY_DICT_ADD_INT(GL_LINE_SMOOTH_HINT);
1747                 PY_DICT_ADD_INT(GL_LINE_STRIP);
1748                 PY_DICT_ADD_INT(GL_LINE_WIDTH);
1749                 PY_DICT_ADD_INT(GL_LINE_WIDTH_GRANULARITY);
1750                 PY_DICT_ADD_INT(GL_LINE_WIDTH_RANGE);
1751                 PY_DICT_ADD_INT(GL_LOGIC_OP_MODE);
1752                 PY_DICT_ADD_INT(GL_MAX_TEXTURE_SIZE);
1753                 PY_DICT_ADD_INT(GL_MAX_VIEWPORT_DIMS);
1754                 PY_DICT_ADD_INT(GL_NAND);
1755                 PY_DICT_ADD_INT(GL_NEAREST);
1756                 PY_DICT_ADD_INT(GL_NEAREST_MIPMAP_LINEAR);
1757                 PY_DICT_ADD_INT(GL_NEAREST_MIPMAP_NEAREST);
1758                 PY_DICT_ADD_INT(GL_NEVER);
1759                 PY_DICT_ADD_INT(GL_NICEST);
1760                 PY_DICT_ADD_INT(GL_NONE);
1761                 PY_DICT_ADD_INT(GL_NOOP);
1762                 PY_DICT_ADD_INT(GL_NOR);
1763                 PY_DICT_ADD_INT(GL_NOTEQUAL);
1764                 PY_DICT_ADD_INT(GL_NO_ERROR);
1765                 PY_DICT_ADD_INT(GL_ONE);
1766                 PY_DICT_ADD_INT(GL_ONE_MINUS_DST_ALPHA);
1767                 PY_DICT_ADD_INT(GL_ONE_MINUS_DST_COLOR);
1768                 PY_DICT_ADD_INT(GL_ONE_MINUS_SRC_ALPHA);
1769                 PY_DICT_ADD_INT(GL_ONE_MINUS_SRC_COLOR);
1770                 PY_DICT_ADD_INT(GL_OR);
1771                 PY_DICT_ADD_INT(GL_OR_INVERTED);
1772                 PY_DICT_ADD_INT(GL_OR_REVERSE);
1773                 PY_DICT_ADD_INT(GL_OUT_OF_MEMORY);
1774                 PY_DICT_ADD_INT(GL_PACK_ALIGNMENT);
1775                 PY_DICT_ADD_INT(GL_PACK_LSB_FIRST);
1776                 PY_DICT_ADD_INT(GL_PACK_ROW_LENGTH);
1777                 PY_DICT_ADD_INT(GL_PACK_SKIP_PIXELS);
1778                 PY_DICT_ADD_INT(GL_PACK_SKIP_ROWS);
1779                 PY_DICT_ADD_INT(GL_PACK_SWAP_BYTES);
1780                 PY_DICT_ADD_INT(GL_POINT);
1781                 PY_DICT_ADD_INT(GL_POINTS);
1782                 PY_DICT_ADD_INT(GL_POINT_SIZE);
1783                 PY_DICT_ADD_INT(GL_POLYGON_MODE);
1784                 PY_DICT_ADD_INT(GL_POLYGON_OFFSET_FACTOR);
1785                 PY_DICT_ADD_INT(GL_POLYGON_OFFSET_FILL);
1786                 PY_DICT_ADD_INT(GL_POLYGON_OFFSET_LINE);
1787                 PY_DICT_ADD_INT(GL_POLYGON_OFFSET_POINT);
1788                 PY_DICT_ADD_INT(GL_POLYGON_OFFSET_UNITS);
1789                 PY_DICT_ADD_INT(GL_POLYGON_SMOOTH);
1790                 PY_DICT_ADD_INT(GL_POLYGON_SMOOTH_HINT);
1791                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_1D);
1792                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D);
1793                 PY_DICT_ADD_INT(GL_R3_G3_B2);
1794                 PY_DICT_ADD_INT(GL_READ_BUFFER);
1795                 PY_DICT_ADD_INT(GL_RED);
1796                 PY_DICT_ADD_INT(GL_RENDERER);
1797                 PY_DICT_ADD_INT(GL_REPEAT);
1798                 PY_DICT_ADD_INT(GL_REPLACE);
1799                 PY_DICT_ADD_INT(GL_RGB);
1800                 PY_DICT_ADD_INT(GL_RGB10);
1801                 PY_DICT_ADD_INT(GL_RGB10_A2);
1802                 PY_DICT_ADD_INT(GL_RGB12);
1803                 PY_DICT_ADD_INT(GL_RGB16);
1804                 PY_DICT_ADD_INT(GL_RGB4);
1805                 PY_DICT_ADD_INT(GL_RGB5);
1806                 PY_DICT_ADD_INT(GL_RGB5_A1);
1807                 PY_DICT_ADD_INT(GL_RGB8);
1808                 PY_DICT_ADD_INT(GL_RGBA);
1809                 PY_DICT_ADD_INT(GL_RGBA12);
1810                 PY_DICT_ADD_INT(GL_RGBA16);
1811                 PY_DICT_ADD_INT(GL_RGBA2);
1812                 PY_DICT_ADD_INT(GL_RGBA4);
1813                 PY_DICT_ADD_INT(GL_RGBA8);
1814                 PY_DICT_ADD_INT(GL_RIGHT);
1815                 PY_DICT_ADD_INT(GL_SCISSOR_BOX);
1816                 PY_DICT_ADD_INT(GL_SCISSOR_TEST);
1817                 PY_DICT_ADD_INT(GL_SET);
1818                 PY_DICT_ADD_INT(GL_SHORT);
1819                 PY_DICT_ADD_INT(GL_SRC_ALPHA);
1820                 PY_DICT_ADD_INT(GL_SRC_ALPHA_SATURATE);
1821                 PY_DICT_ADD_INT(GL_SRC_COLOR);
1822                 PY_DICT_ADD_INT(GL_STENCIL);
1823                 PY_DICT_ADD_INT(GL_STENCIL_BUFFER_BIT);
1824                 PY_DICT_ADD_INT(GL_STENCIL_CLEAR_VALUE);
1825                 PY_DICT_ADD_INT(GL_STENCIL_FAIL);
1826                 PY_DICT_ADD_INT(GL_STENCIL_FUNC);
1827                 PY_DICT_ADD_INT(GL_STENCIL_INDEX);
1828                 PY_DICT_ADD_INT(GL_STENCIL_PASS_DEPTH_FAIL);
1829                 PY_DICT_ADD_INT(GL_STENCIL_PASS_DEPTH_PASS);
1830                 PY_DICT_ADD_INT(GL_STENCIL_REF);
1831                 PY_DICT_ADD_INT(GL_STENCIL_TEST);
1832                 PY_DICT_ADD_INT(GL_STENCIL_VALUE_MASK);
1833                 PY_DICT_ADD_INT(GL_STENCIL_WRITEMASK);
1834                 PY_DICT_ADD_INT(GL_STEREO);
1835                 PY_DICT_ADD_INT(GL_SUBPIXEL_BITS);
1836                 PY_DICT_ADD_INT(GL_TEXTURE);
1837                 PY_DICT_ADD_INT(GL_TEXTURE_1D);
1838                 PY_DICT_ADD_INT(GL_TEXTURE_2D);
1839                 PY_DICT_ADD_INT(GL_TEXTURE_ALPHA_SIZE);
1840                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_1D);
1841                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D);
1842                 PY_DICT_ADD_INT(GL_TEXTURE_BLUE_SIZE);
1843                 PY_DICT_ADD_INT(GL_TEXTURE_BORDER_COLOR);
1844                 PY_DICT_ADD_INT(GL_TEXTURE_GREEN_SIZE);
1845                 PY_DICT_ADD_INT(GL_TEXTURE_HEIGHT);
1846                 PY_DICT_ADD_INT(GL_TEXTURE_INTERNAL_FORMAT);
1847                 PY_DICT_ADD_INT(GL_TEXTURE_MAG_FILTER);
1848                 PY_DICT_ADD_INT(GL_TEXTURE_MIN_FILTER);
1849                 PY_DICT_ADD_INT(GL_TEXTURE_RED_SIZE);
1850                 PY_DICT_ADD_INT(GL_TEXTURE_WIDTH);
1851                 PY_DICT_ADD_INT(GL_TEXTURE_WRAP_S);
1852                 PY_DICT_ADD_INT(GL_TEXTURE_WRAP_T);
1853                 PY_DICT_ADD_INT(GL_TRIANGLES);
1854                 PY_DICT_ADD_INT(GL_TRIANGLE_FAN);
1855                 PY_DICT_ADD_INT(GL_TRIANGLE_STRIP);
1856                 PY_DICT_ADD_INT(GL_TRUE);
1857                 PY_DICT_ADD_INT(GL_UNPACK_ALIGNMENT);
1858                 PY_DICT_ADD_INT(GL_UNPACK_LSB_FIRST);
1859                 PY_DICT_ADD_INT(GL_UNPACK_ROW_LENGTH);
1860                 PY_DICT_ADD_INT(GL_UNPACK_SKIP_PIXELS);
1861                 PY_DICT_ADD_INT(GL_UNPACK_SKIP_ROWS);
1862                 PY_DICT_ADD_INT(GL_UNPACK_SWAP_BYTES);
1863                 PY_DICT_ADD_INT(GL_UNSIGNED_BYTE);
1864                 PY_DICT_ADD_INT(GL_UNSIGNED_INT);
1865                 PY_DICT_ADD_INT(GL_UNSIGNED_SHORT);
1866                 PY_DICT_ADD_INT(GL_VENDOR);
1867                 PY_DICT_ADD_INT(GL_VERSION);
1868                 PY_DICT_ADD_INT(GL_VIEWPORT);
1869                 PY_DICT_ADD_INT(GL_XOR);
1870                 PY_DICT_ADD_INT(GL_ZERO);
1871         }
1872
1873         /* GL_VERSION_1_2 */
1874         {
1875                 PY_DICT_ADD_INT(GL_ALIASED_LINE_WIDTH_RANGE);
1876                 PY_DICT_ADD_INT(GL_BGR);
1877                 PY_DICT_ADD_INT(GL_BGRA);
1878                 PY_DICT_ADD_INT(GL_CLAMP_TO_EDGE);
1879                 PY_DICT_ADD_INT(GL_MAX_3D_TEXTURE_SIZE);
1880                 PY_DICT_ADD_INT(GL_MAX_ELEMENTS_INDICES);
1881                 PY_DICT_ADD_INT(GL_MAX_ELEMENTS_VERTICES);
1882                 PY_DICT_ADD_INT(GL_PACK_IMAGE_HEIGHT);
1883                 PY_DICT_ADD_INT(GL_PACK_SKIP_IMAGES);
1884                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_3D);
1885                 PY_DICT_ADD_INT(GL_SMOOTH_LINE_WIDTH_GRANULARITY);
1886                 PY_DICT_ADD_INT(GL_SMOOTH_LINE_WIDTH_RANGE);
1887                 PY_DICT_ADD_INT(GL_SMOOTH_POINT_SIZE_GRANULARITY);
1888                 PY_DICT_ADD_INT(GL_SMOOTH_POINT_SIZE_RANGE);
1889                 PY_DICT_ADD_INT(GL_TEXTURE_3D);
1890                 PY_DICT_ADD_INT(GL_TEXTURE_BASE_LEVEL);
1891                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_3D);
1892                 PY_DICT_ADD_INT(GL_TEXTURE_DEPTH);
1893                 PY_DICT_ADD_INT(GL_TEXTURE_MAX_LEVEL);
1894                 PY_DICT_ADD_INT(GL_TEXTURE_MAX_LOD);
1895                 PY_DICT_ADD_INT(GL_TEXTURE_MIN_LOD);
1896                 PY_DICT_ADD_INT(GL_TEXTURE_WRAP_R);
1897                 PY_DICT_ADD_INT(GL_UNPACK_IMAGE_HEIGHT);
1898                 PY_DICT_ADD_INT(GL_UNPACK_SKIP_IMAGES);
1899                 PY_DICT_ADD_INT(GL_UNSIGNED_BYTE_2_3_3_REV);
1900                 PY_DICT_ADD_INT(GL_UNSIGNED_BYTE_3_3_2);
1901                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_10_10_10_2);
1902                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_2_10_10_10_REV);
1903                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_8_8_8_8);
1904                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_8_8_8_8_REV);
1905                 PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_1_5_5_5_REV);
1906                 PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_4_4_4_4);
1907                 PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_4_4_4_4_REV);
1908                 PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_5_5_1);
1909                 PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_6_5);
1910                 PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_6_5_REV);
1911         }
1912
1913         /* GL_VERSION_1_3 */
1914         {
1915                 PY_DICT_ADD_INT(GL_ACTIVE_TEXTURE);
1916                 PY_DICT_ADD_INT(GL_CLAMP_TO_BORDER);
1917                 PY_DICT_ADD_INT(GL_COMPRESSED_RGB);
1918                 PY_DICT_ADD_INT(GL_COMPRESSED_RGBA);
1919                 PY_DICT_ADD_INT(GL_COMPRESSED_TEXTURE_FORMATS);
1920                 PY_DICT_ADD_INT(GL_MAX_CUBE_MAP_TEXTURE_SIZE);
1921                 PY_DICT_ADD_INT(GL_MULTISAMPLE);
1922                 PY_DICT_ADD_INT(GL_NUM_COMPRESSED_TEXTURE_FORMATS);
1923                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_CUBE_MAP);
1924                 PY_DICT_ADD_INT(GL_SAMPLES);
1925                 PY_DICT_ADD_INT(GL_SAMPLE_ALPHA_TO_COVERAGE);
1926                 PY_DICT_ADD_INT(GL_SAMPLE_ALPHA_TO_ONE);
1927                 PY_DICT_ADD_INT(GL_SAMPLE_BUFFERS);
1928                 PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE);
1929                 PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE_INVERT);
1930                 PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE_VALUE);
1931                 PY_DICT_ADD_INT(GL_TEXTURE0);
1932                 PY_DICT_ADD_INT(GL_TEXTURE1);
1933                 PY_DICT_ADD_INT(GL_TEXTURE10);
1934                 PY_DICT_ADD_INT(GL_TEXTURE11);
1935                 PY_DICT_ADD_INT(GL_TEXTURE12);
1936                 PY_DICT_ADD_INT(GL_TEXTURE13);
1937                 PY_DICT_ADD_INT(GL_TEXTURE14);
1938                 PY_DICT_ADD_INT(GL_TEXTURE15);
1939                 PY_DICT_ADD_INT(GL_TEXTURE16);
1940                 PY_DICT_ADD_INT(GL_TEXTURE17);
1941                 PY_DICT_ADD_INT(GL_TEXTURE18);
1942                 PY_DICT_ADD_INT(GL_TEXTURE19);
1943                 PY_DICT_ADD_INT(GL_TEXTURE2);
1944                 PY_DICT_ADD_INT(GL_TEXTURE20);
1945                 PY_DICT_ADD_INT(GL_TEXTURE21);
1946                 PY_DICT_ADD_INT(GL_TEXTURE22);
1947                 PY_DICT_ADD_INT(GL_TEXTURE23);
1948                 PY_DICT_ADD_INT(GL_TEXTURE24);
1949                 PY_DICT_ADD_INT(GL_TEXTURE25);
1950                 PY_DICT_ADD_INT(GL_TEXTURE26);
1951                 PY_DICT_ADD_INT(GL_TEXTURE27);
1952                 PY_DICT_ADD_INT(GL_TEXTURE28);
1953                 PY_DICT_ADD_INT(GL_TEXTURE29);
1954                 PY_DICT_ADD_INT(GL_TEXTURE3);
1955                 PY_DICT_ADD_INT(GL_TEXTURE30);
1956                 PY_DICT_ADD_INT(GL_TEXTURE31);
1957                 PY_DICT_ADD_INT(GL_TEXTURE4);
1958                 PY_DICT_ADD_INT(GL_TEXTURE5);
1959                 PY_DICT_ADD_INT(GL_TEXTURE6);
1960                 PY_DICT_ADD_INT(GL_TEXTURE7);
1961                 PY_DICT_ADD_INT(GL_TEXTURE8);
1962                 PY_DICT_ADD_INT(GL_TEXTURE9);
1963                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_CUBE_MAP);
1964                 PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSED);
1965                 PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSED_IMAGE_SIZE);
1966                 PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSION_HINT);
1967                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP);
1968                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X);
1969                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);
1970                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
1971                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
1972                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y);
1973                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z);
1974         }
1975
1976         /* GL_VERSION_1_4 */
1977         {
1978                 PY_DICT_ADD_INT(GL_BLEND_DST_ALPHA);
1979                 PY_DICT_ADD_INT(GL_BLEND_DST_RGB);
1980                 PY_DICT_ADD_INT(GL_BLEND_SRC_ALPHA);
1981                 PY_DICT_ADD_INT(GL_BLEND_SRC_RGB);
1982                 PY_DICT_ADD_INT(GL_CONSTANT_ALPHA);
1983                 PY_DICT_ADD_INT(GL_CONSTANT_COLOR);
1984                 PY_DICT_ADD_INT(GL_DECR_WRAP);
1985                 PY_DICT_ADD_INT(GL_DEPTH_COMPONENT16);
1986                 PY_DICT_ADD_INT(GL_DEPTH_COMPONENT24);
1987                 PY_DICT_ADD_INT(GL_DEPTH_COMPONENT32);
1988                 PY_DICT_ADD_INT(GL_FUNC_ADD);
1989                 PY_DICT_ADD_INT(GL_FUNC_REVERSE_SUBTRACT);
1990                 PY_DICT_ADD_INT(GL_FUNC_SUBTRACT);
1991                 PY_DICT_ADD_INT(GL_INCR_WRAP);
1992                 PY_DICT_ADD_INT(GL_MAX);
1993                 PY_DICT_ADD_INT(GL_MAX_TEXTURE_LOD_BIAS);
1994                 PY_DICT_ADD_INT(GL_MIN);
1995                 PY_DICT_ADD_INT(GL_MIRRORED_REPEAT);
1996                 PY_DICT_ADD_INT(GL_ONE_MINUS_CONSTANT_ALPHA);
1997                 PY_DICT_ADD_INT(GL_ONE_MINUS_CONSTANT_COLOR);
1998                 PY_DICT_ADD_INT(GL_POINT_FADE_THRESHOLD_SIZE);
1999                 PY_DICT_ADD_INT(GL_TEXTURE_COMPARE_FUNC);
2000                 PY_DICT_ADD_INT(GL_TEXTURE_COMPARE_MODE);
2001                 PY_DICT_ADD_INT(GL_TEXTURE_DEPTH_SIZE);
2002                 PY_DICT_ADD_INT(GL_TEXTURE_LOD_BIAS);
2003         }
2004
2005         /* GL_VERSION_1_5 */
2006         {
2007                 PY_DICT_ADD_INT(GL_ARRAY_BUFFER);
2008                 PY_DICT_ADD_INT(GL_ARRAY_BUFFER_BINDING);
2009                 PY_DICT_ADD_INT(GL_BUFFER_ACCESS);
2010                 PY_DICT_ADD_INT(GL_BUFFER_MAPPED);
2011                 PY_DICT_ADD_INT(GL_BUFFER_MAP_POINTER);
2012                 PY_DICT_ADD_INT(GL_BUFFER_SIZE);
2013                 PY_DICT_ADD_INT(GL_BUFFER_USAGE);
2014                 PY_DICT_ADD_INT(GL_CURRENT_QUERY);
2015                 PY_DICT_ADD_INT(GL_DYNAMIC_COPY);
2016                 PY_DICT_ADD_INT(GL_DYNAMIC_DRAW);
2017                 PY_DICT_ADD_INT(GL_DYNAMIC_READ);
2018                 PY_DICT_ADD_INT(GL_ELEMENT_ARRAY_BUFFER);
2019                 PY_DICT_ADD_INT(GL_ELEMENT_ARRAY_BUFFER_BINDING);
2020                 PY_DICT_ADD_INT(GL_QUERY_COUNTER_BITS);
2021                 PY_DICT_ADD_INT(GL_QUERY_RESULT);
2022                 PY_DICT_ADD_INT(GL_QUERY_RESULT_AVAILABLE);
2023                 PY_DICT_ADD_INT(GL_READ_ONLY);
2024                 PY_DICT_ADD_INT(GL_READ_WRITE);
2025                 PY_DICT_ADD_INT(GL_SAMPLES_PASSED);
2026                 PY_DICT_ADD_INT(GL_STATIC_COPY);
2027                 PY_DICT_ADD_INT(GL_STATIC_DRAW);
2028                 PY_DICT_ADD_INT(GL_STATIC_READ);
2029                 PY_DICT_ADD_INT(GL_STREAM_COPY);
2030                 PY_DICT_ADD_INT(GL_STREAM_DRAW);
2031                 PY_DICT_ADD_INT(GL_STREAM_READ);
2032                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
2033                 PY_DICT_ADD_INT(GL_WRITE_ONLY);
2034         }
2035
2036         /* GL_VERSION_2_0 */
2037         {
2038                 PY_DICT_ADD_INT(GL_ACTIVE_ATTRIBUTES);
2039                 PY_DICT_ADD_INT(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
2040                 PY_DICT_ADD_INT(GL_ACTIVE_UNIFORMS);
2041                 PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_MAX_LENGTH);
2042                 PY_DICT_ADD_INT(GL_ATTACHED_SHADERS);
2043                 PY_DICT_ADD_INT(GL_BLEND_EQUATION_ALPHA);
2044                 PY_DICT_ADD_INT(GL_BLEND_EQUATION_RGB);
2045                 PY_DICT_ADD_INT(GL_BOOL);
2046                 PY_DICT_ADD_INT(GL_BOOL_VEC2);
2047                 PY_DICT_ADD_INT(GL_BOOL_VEC3);
2048                 PY_DICT_ADD_INT(GL_BOOL_VEC4);
2049                 PY_DICT_ADD_INT(GL_COMPILE_STATUS);
2050                 PY_DICT_ADD_INT(GL_CURRENT_PROGRAM);
2051                 PY_DICT_ADD_INT(GL_CURRENT_VERTEX_ATTRIB);
2052                 PY_DICT_ADD_INT(GL_DELETE_STATUS);
2053                 PY_DICT_ADD_INT(GL_DRAW_BUFFER0);
2054                 PY_DICT_ADD_INT(GL_DRAW_BUFFER1);
2055                 PY_DICT_ADD_INT(GL_DRAW_BUFFER10);
2056                 PY_DICT_ADD_INT(GL_DRAW_BUFFER11);
2057                 PY_DICT_ADD_INT(GL_DRAW_BUFFER12);
2058                 PY_DICT_ADD_INT(GL_DRAW_BUFFER13);
2059                 PY_DICT_ADD_INT(GL_DRAW_BUFFER14);
2060                 PY_DICT_ADD_INT(GL_DRAW_BUFFER15);
2061                 PY_DICT_ADD_INT(GL_DRAW_BUFFER2);
2062                 PY_DICT_ADD_INT(GL_DRAW_BUFFER3);
2063                 PY_DICT_ADD_INT(GL_DRAW_BUFFER4);
2064                 PY_DICT_ADD_INT(GL_DRAW_BUFFER5);
2065                 PY_DICT_ADD_INT(GL_DRAW_BUFFER6);
2066                 PY_DICT_ADD_INT(GL_DRAW_BUFFER7);
2067                 PY_DICT_ADD_INT(GL_DRAW_BUFFER8);
2068                 PY_DICT_ADD_INT(GL_DRAW_BUFFER9);
2069                 PY_DICT_ADD_INT(GL_FLOAT_MAT2);
2070                 PY_DICT_ADD_INT(GL_FLOAT_MAT3);
2071                 PY_DICT_ADD_INT(GL_FLOAT_MAT4);
2072                 PY_DICT_ADD_INT(GL_FLOAT_VEC2);
2073                 PY_DICT_ADD_INT(GL_FLOAT_VEC3);
2074                 PY_DICT_ADD_INT(GL_FLOAT_VEC4);
2075                 PY_DICT_ADD_INT(GL_FRAGMENT_SHADER);
2076                 PY_DICT_ADD_INT(GL_FRAGMENT_SHADER_DERIVATIVE_HINT);
2077                 PY_DICT_ADD_INT(GL_INFO_LOG_LENGTH);
2078                 PY_DICT_ADD_INT(GL_INT_VEC2);
2079                 PY_DICT_ADD_INT(GL_INT_VEC3);
2080                 PY_DICT_ADD_INT(GL_INT_VEC4);
2081                 PY_DICT_ADD_INT(GL_LINK_STATUS);
2082                 PY_DICT_ADD_INT(GL_LOWER_LEFT);
2083                 PY_DICT_ADD_INT(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
2084                 PY_DICT_ADD_INT(GL_MAX_DRAW_BUFFERS);
2085                 PY_DICT_ADD_INT(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
2086                 PY_DICT_ADD_INT(GL_MAX_TEXTURE_IMAGE_UNITS);
2087                 PY_DICT_ADD_INT(GL_MAX_VARYING_FLOATS);
2088                 PY_DICT_ADD_INT(GL_MAX_VERTEX_ATTRIBS);
2089                 PY_DICT_ADD_INT(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
2090                 PY_DICT_ADD_INT(GL_MAX_VERTEX_UNIFORM_COMPONENTS);
2091                 PY_DICT_ADD_INT(GL_POINT_SPRITE_COORD_ORIGIN);
2092                 PY_DICT_ADD_INT(GL_SAMPLER_1D);
2093                 PY_DICT_ADD_INT(GL_SAMPLER_1D_SHADOW);
2094                 PY_DICT_ADD_INT(GL_SAMPLER_2D);
2095                 PY_DICT_ADD_INT(GL_SAMPLER_2D_SHADOW);
2096                 PY_DICT_ADD_INT(GL_SAMPLER_3D);
2097                 PY_DICT_ADD_INT(GL_SAMPLER_CUBE);
2098                 PY_DICT_ADD_INT(GL_SHADER_SOURCE_LENGTH);
2099                 PY_DICT_ADD_INT(GL_SHADER_TYPE);
2100                 PY_DICT_ADD_INT(GL_SHADING_LANGUAGE_VERSION);
2101                 PY_DICT_ADD_INT(GL_STENCIL_BACK_FAIL);
2102                 PY_DICT_ADD_INT(GL_STENCIL_BACK_FUNC);
2103                 PY_DICT_ADD_INT(GL_STENCIL_BACK_PASS_DEPTH_FAIL);
2104                 PY_DICT_ADD_INT(GL_STENCIL_BACK_PASS_DEPTH_PASS);
2105                 PY_DICT_ADD_INT(GL_STENCIL_BACK_REF);
2106                 PY_DICT_ADD_INT(GL_STENCIL_BACK_VALUE_MASK);
2107                 PY_DICT_ADD_INT(GL_STENCIL_BACK_WRITEMASK);
2108                 PY_DICT_ADD_INT(GL_UPPER_LEFT);
2109                 PY_DICT_ADD_INT(GL_VALIDATE_STATUS);
2110                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_ENABLED);
2111                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_NORMALIZED);
2112                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_POINTER);
2113                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_SIZE);
2114                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_STRIDE);
2115                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_TYPE);
2116                 PY_DICT_ADD_INT(GL_VERTEX_PROGRAM_POINT_SIZE);
2117                 PY_DICT_ADD_INT(GL_VERTEX_SHADER);
2118         }
2119
2120         /* GL_VERSION_2_1 */
2121         {
2122                 PY_DICT_ADD_INT(GL_COMPRESSED_SRGB);
2123                 PY_DICT_ADD_INT(GL_COMPRESSED_SRGB_ALPHA);
2124                 PY_DICT_ADD_INT(GL_FLOAT_MAT2x3);
2125                 PY_DICT_ADD_INT(GL_FLOAT_MAT2x4);
2126                 PY_DICT_ADD_INT(GL_FLOAT_MAT3x2);
2127                 PY_DICT_ADD_INT(GL_FLOAT_MAT3x4);
2128                 PY_DICT_ADD_INT(GL_FLOAT_MAT4x2);
2129                 PY_DICT_ADD_INT(GL_FLOAT_MAT4x3);
2130                 PY_DICT_ADD_INT(GL_PIXEL_PACK_BUFFER);
2131                 PY_DICT_ADD_INT(GL_PIXEL_PACK_BUFFER_BINDING);
2132                 PY_DICT_ADD_INT(GL_PIXEL_UNPACK_BUFFER);
2133                 PY_DICT_ADD_INT(GL_PIXEL_UNPACK_BUFFER_BINDING);
2134                 PY_DICT_ADD_INT(GL_SRGB);
2135                 PY_DICT_ADD_INT(GL_SRGB8);
2136                 PY_DICT_ADD_INT(GL_SRGB8_ALPHA8);
2137                 PY_DICT_ADD_INT(GL_SRGB_ALPHA);
2138         }
2139
2140         /* GL_VERSION_3_0 */
2141         {
2142                 PY_DICT_ADD_INT(GL_BGRA_INTEGER);
2143                 PY_DICT_ADD_INT(GL_BGR_INTEGER);
2144                 PY_DICT_ADD_INT(GL_BLUE_INTEGER);
2145                 PY_DICT_ADD_INT(GL_BUFFER_ACCESS_FLAGS);
2146                 PY_DICT_ADD_INT(GL_BUFFER_MAP_LENGTH);
2147                 PY_DICT_ADD_INT(GL_BUFFER_MAP_OFFSET);
2148                 PY_DICT_ADD_INT(GL_CLAMP_READ_COLOR);
2149                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE0);
2150                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE1);
2151                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE2);
2152                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE3);
2153                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE4);
2154                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE5);
2155 #if 0
2156                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE6);
2157                 PY_DICT_ADD_INT(GL_CLIP_DISTANCE7);
2158 #endif
2159                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT0);
2160                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT1);
2161                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT2);
2162                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT3);
2163                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT4);
2164                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT5);
2165                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT6);
2166                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT7);
2167                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT8);
2168                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT9);
2169                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT10);
2170                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT11);
2171                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT12);
2172                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT13);
2173                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT14);
2174                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT15);
2175 #if 0
2176                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT16);
2177                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT17);
2178                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT18);
2179                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT19);
2180                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT20);
2181                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT21);
2182                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT22);
2183                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT23);
2184                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT24);
2185                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT25);
2186                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT26);
2187                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT27);
2188                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT28);
2189                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT29);
2190                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT30);
2191                 PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT31);
2192 #endif
2193                 PY_DICT_ADD_INT(GL_COMPARE_REF_TO_TEXTURE);
2194                 PY_DICT_ADD_INT(GL_COMPRESSED_RED);
2195                 PY_DICT_ADD_INT(GL_COMPRESSED_RED_RGTC1);
2196                 PY_DICT_ADD_INT(GL_COMPRESSED_RG);
2197                 PY_DICT_ADD_INT(GL_COMPRESSED_RG_RGTC2);
2198                 PY_DICT_ADD_INT(GL_COMPRESSED_SIGNED_RED_RGTC1);
2199                 PY_DICT_ADD_INT(GL_COMPRESSED_SIGNED_RG_RGTC2);
2200                 PY_DICT_ADD_INT(GL_CONTEXT_FLAGS);
2201                 PY_DICT_ADD_INT(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT);
2202                 PY_DICT_ADD_INT(GL_DEPTH24_STENCIL8);
2203                 PY_DICT_ADD_INT(GL_DEPTH32F_STENCIL8);
2204                 PY_DICT_ADD_INT(GL_DEPTH_ATTACHMENT);
2205                 PY_DICT_ADD_INT(GL_DEPTH_COMPONENT32F);
2206                 PY_DICT_ADD_INT(GL_DEPTH_STENCIL);
2207                 PY_DICT_ADD_INT(GL_DEPTH_STENCIL_ATTACHMENT);
2208                 PY_DICT_ADD_INT(GL_DRAW_FRAMEBUFFER);
2209                 PY_DICT_ADD_INT(GL_DRAW_FRAMEBUFFER_BINDING);
2210                 PY_DICT_ADD_INT(GL_FIXED_ONLY);
2211                 PY_DICT_ADD_INT(GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
2212                 PY_DICT_ADD_INT(GL_FRAMEBUFFER);
2213                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE);
2214                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE);
2215                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING);
2216                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE);
2217                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE);
2218                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE);
2219                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
2220                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
2221                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE);
2222                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE);
2223                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE);
2224                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER);
2225                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL);
2226                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_BINDING);
2227                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_COMPLETE);
2228                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_DEFAULT);
2229                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
2230                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER);
2231                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
2232                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE);
2233                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER);
2234                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_SRGB);
2235                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_UNDEFINED);
2236                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_UNSUPPORTED);
2237                 PY_DICT_ADD_INT(GL_GREEN_INTEGER);
2238                 PY_DICT_ADD_INT(GL_HALF_FLOAT);
2239                 PY_DICT_ADD_INT(GL_INDEX);
2240                 PY_DICT_ADD_INT(GL_INTERLEAVED_ATTRIBS);
2241                 PY_DICT_ADD_INT(GL_INT_SAMPLER_1D);
2242                 PY_DICT_ADD_INT(GL_INT_SAMPLER_1D_ARRAY);
2243                 PY_DICT_ADD_INT(GL_INT_SAMPLER_2D);
2244                 PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_ARRAY);
2245                 PY_DICT_ADD_INT(GL_INT_SAMPLER_3D);
2246                 PY_DICT_ADD_INT(GL_INT_SAMPLER_CUBE);
2247                 PY_DICT_ADD_INT(GL_INVALID_FRAMEBUFFER_OPERATION);
2248                 PY_DICT_ADD_INT(GL_MAJOR_VERSION);
2249                 PY_DICT_ADD_INT(GL_MAP_FLUSH_EXPLICIT_BIT);
2250                 PY_DICT_ADD_INT(GL_MAP_INVALIDATE_BUFFER_BIT);
2251                 PY_DICT_ADD_INT(GL_MAP_INVALIDATE_RANGE_BIT);
2252                 PY_DICT_ADD_INT(GL_MAP_READ_BIT);
2253                 PY_DICT_ADD_INT(GL_MAP_UNSYNCHRONIZED_BIT);
2254                 PY_DICT_ADD_INT(GL_MAP_WRITE_BIT);
2255                 PY_DICT_ADD_INT(GL_MAX_ARRAY_TEXTURE_LAYERS);
2256                 PY_DICT_ADD_INT(GL_MAX_CLIP_DISTANCES);
2257                 PY_DICT_ADD_INT(GL_MAX_COLOR_ATTACHMENTS);
2258                 PY_DICT_ADD_INT(GL_MAX_PROGRAM_TEXEL_OFFSET);
2259                 PY_DICT_ADD_INT(GL_MAX_RENDERBUFFER_SIZE);
2260                 PY_DICT_ADD_INT(GL_MAX_SAMPLES);
2261                 PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS);
2262                 PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);
2263                 PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS);
2264                 PY_DICT_ADD_INT(GL_MAX_VARYING_COMPONENTS);
2265                 PY_DICT_ADD_INT(GL_MINOR_VERSION);
2266                 PY_DICT_ADD_INT(GL_MIN_PROGRAM_TEXEL_OFFSET);
2267                 PY_DICT_ADD_INT(GL_NUM_EXTENSIONS);
2268                 PY_DICT_ADD_INT(GL_PRIMITIVES_GENERATED);
2269                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_1D_ARRAY);
2270                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_ARRAY);
2271                 PY_DICT_ADD_INT(GL_QUERY_BY_REGION_NO_WAIT);
2272                 PY_DICT_ADD_INT(GL_QUERY_BY_REGION_WAIT);
2273                 PY_DICT_ADD_INT(GL_QUERY_NO_WAIT);
2274                 PY_DICT_ADD_INT(GL_QUERY_WAIT);
2275                 PY_DICT_ADD_INT(GL_R11F_G11F_B10F);
2276                 PY_DICT_ADD_INT(GL_R16);
2277                 PY_DICT_ADD_INT(GL_R16F);
2278                 PY_DICT_ADD_INT(GL_R16I);
2279                 PY_DICT_ADD_INT(GL_R16UI);
2280                 PY_DICT_ADD_INT(GL_R32F);
2281                 PY_DICT_ADD_INT(GL_R32I);
2282                 PY_DICT_ADD_INT(GL_R32UI);
2283                 PY_DICT_ADD_INT(GL_R8);
2284                 PY_DICT_ADD_INT(GL_R8I);
2285                 PY_DICT_ADD_INT(GL_R8UI);
2286                 PY_DICT_ADD_INT(GL_RASTERIZER_DISCARD);
2287                 PY_DICT_ADD_INT(GL_READ_FRAMEBUFFER);
2288                 PY_DICT_ADD_INT(GL_READ_FRAMEBUFFER_BINDING);
2289                 PY_DICT_ADD_INT(GL_RED_INTEGER);
2290                 PY_DICT_ADD_INT(GL_RENDERBUFFER);
2291                 PY_DICT_ADD_INT(GL_RENDERBUFFER_ALPHA_SIZE);
2292                 PY_DICT_ADD_INT(GL_RENDERBUFFER_BINDING);
2293                 PY_DICT_ADD_INT(GL_RENDERBUFFER_BLUE_SIZE);
2294                 PY_DICT_ADD_INT(GL_RENDERBUFFER_DEPTH_SIZE);
2295                 PY_DICT_ADD_INT(GL_RENDERBUFFER_GREEN_SIZE);
2296                 PY_DICT_ADD_INT(GL_RENDERBUFFER_HEIGHT);
2297                 PY_DICT_ADD_INT(GL_RENDERBUFFER_INTERNAL_FORMAT);
2298                 PY_DICT_ADD_INT(GL_RENDERBUFFER_RED_SIZE);
2299                 PY_DICT_ADD_INT(GL_RENDERBUFFER_SAMPLES);
2300                 PY_DICT_ADD_INT(GL_RENDERBUFFER_STENCIL_SIZE);
2301                 PY_DICT_ADD_INT(GL_RENDERBUFFER_WIDTH);
2302                 PY_DICT_ADD_INT(GL_RG);
2303                 PY_DICT_ADD_INT(GL_RG16);
2304                 PY_DICT_ADD_INT(GL_RG16F);
2305                 PY_DICT_ADD_INT(GL_RG16I);
2306                 PY_DICT_ADD_INT(GL_RG16UI);
2307                 PY_DICT_ADD_INT(GL_RG32F);
2308                 PY_DICT_ADD_INT(GL_RG32I);
2309                 PY_DICT_ADD_INT(GL_RG32UI);
2310                 PY_DICT_ADD_INT(GL_RG8);
2311                 PY_DICT_ADD_INT(GL_RG8I);
2312                 PY_DICT_ADD_INT(GL_RG8UI);
2313                 PY_DICT_ADD_INT(GL_RGB16F);
2314                 PY_DICT_ADD_INT(GL_RGB16I);
2315                 PY_DICT_ADD_INT(GL_RGB16UI);
2316                 PY_DICT_ADD_INT(GL_RGB32F);
2317                 PY_DICT_ADD_INT(GL_RGB32I);
2318                 PY_DICT_ADD_INT(GL_RGB32UI);
2319                 PY_DICT_ADD_INT(GL_RGB8I);
2320                 PY_DICT_ADD_INT(GL_RGB8UI);
2321                 PY_DICT_ADD_INT(GL_RGB9_E5);
2322                 PY_DICT_ADD_INT(GL_RGBA16F);
2323                 PY_DICT_ADD_INT(GL_RGBA16I);
2324                 PY_DICT_ADD_INT(GL_RGBA16UI);
2325                 PY_DICT_ADD_INT(GL_RGBA32F);
2326                 PY_DICT_ADD_INT(GL_RGBA32I);
2327                 PY_DICT_ADD_INT(GL_RGBA32UI);
2328                 PY_DICT_ADD_INT(GL_RGBA8I);
2329                 PY_DICT_ADD_INT(GL_RGBA8UI);
2330                 PY_DICT_ADD_INT(GL_RGBA_INTEGER);
2331                 PY_DICT_ADD_INT(GL_RGB_INTEGER);
2332                 PY_DICT_ADD_INT(GL_RG_INTEGER);
2333                 PY_DICT_ADD_INT(GL_SAMPLER_1D_ARRAY);
2334                 PY_DICT_ADD_INT(GL_SAMPLER_1D_ARRAY_SHADOW);
2335                 PY_DICT_ADD_INT(GL_SAMPLER_2D_ARRAY);
2336                 PY_DICT_ADD_INT(GL_SAMPLER_2D_ARRAY_SHADOW);
2337                 PY_DICT_ADD_INT(GL_SAMPLER_CUBE_SHADOW);
2338                 PY_DICT_ADD_INT(GL_SEPARATE_ATTRIBS);
2339                 PY_DICT_ADD_INT(GL_STENCIL_ATTACHMENT);
2340                 PY_DICT_ADD_INT(GL_STENCIL_INDEX1);
2341                 PY_DICT_ADD_INT(GL_STENCIL_INDEX16);
2342                 PY_DICT_ADD_INT(GL_STENCIL_INDEX4);
2343                 PY_DICT_ADD_INT(GL_STENCIL_INDEX8);
2344                 PY_DICT_ADD_INT(GL_TEXTURE_1D_ARRAY);
2345                 PY_DICT_ADD_INT(GL_TEXTURE_2D_ARRAY);
2346                 PY_DICT_ADD_INT(GL_TEXTURE_ALPHA_TYPE);
2347                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_1D_ARRAY);
2348                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_ARRAY);
2349                 PY_DICT_ADD_INT(GL_TEXTURE_BLUE_TYPE);
2350                 PY_DICT_ADD_INT(GL_TEXTURE_DEPTH_TYPE);
2351                 PY_DICT_ADD_INT(GL_TEXTURE_GREEN_TYPE);
2352                 PY_DICT_ADD_INT(GL_TEXTURE_RED_TYPE);
2353                 PY_DICT_ADD_INT(GL_TEXTURE_SHARED_SIZE);
2354                 PY_DICT_ADD_INT(GL_TEXTURE_STENCIL_SIZE);
2355                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER);
2356                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING);
2357                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_MODE);
2358                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_SIZE);
2359                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_START);
2360                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
2361                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_VARYINGS);
2362                 PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH);
2363                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_10F_11F_11F_REV);
2364                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_24_8);
2365                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_5_9_9_9_REV);
2366                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_1D);
2367                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY);
2368                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D);
2369                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY);
2370                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_3D);
2371                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_CUBE);
2372                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC2);
2373                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC3);
2374                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC4);
2375                 PY_DICT_ADD_INT(GL_UNSIGNED_NORMALIZED);
2376                 PY_DICT_ADD_INT(GL_VERTEX_ARRAY_BINDING);
2377                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_INTEGER);
2378         }
2379
2380         /* GL_VERSION_3_1 */
2381         {
2382                 PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_BLOCKS);
2383                 PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH);
2384                 PY_DICT_ADD_INT(GL_COPY_READ_BUFFER);
2385                 PY_DICT_ADD_INT(GL_COPY_WRITE_BUFFER);
2386                 PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_RECT);
2387                 PY_DICT_ADD_INT(GL_INT_SAMPLER_BUFFER);
2388                 PY_DICT_ADD_INT(GL_INVALID_INDEX);
2389                 PY_DICT_ADD_INT(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS);
2390                 PY_DICT_ADD_INT(GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS);
2391                 PY_DICT_ADD_INT(GL_MAX_COMBINED_UNIFORM_BLOCKS);
2392                 PY_DICT_ADD_INT(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS);
2393                 PY_DICT_ADD_INT(GL_MAX_FRAGMENT_UNIFORM_BLOCKS);
2394                 PY_DICT_ADD_INT(GL_MAX_GEOMETRY_UNIFORM_BLOCKS);
2395                 PY_DICT_ADD_INT(GL_MAX_RECTANGLE_TEXTURE_SIZE);
2396                 PY_DICT_ADD_INT(GL_MAX_TEXTURE_BUFFER_SIZE);
2397                 PY_DICT_ADD_INT(GL_MAX_UNIFORM_BLOCK_SIZE);
2398                 PY_DICT_ADD_INT(GL_MAX_UNIFORM_BUFFER_BINDINGS);
2399                 PY_DICT_ADD_INT(GL_MAX_VERTEX_UNIFORM_BLOCKS);
2400                 PY_DICT_ADD_INT(GL_PRIMITIVE_RESTART);
2401                 PY_DICT_ADD_INT(GL_PRIMITIVE_RESTART_INDEX);
2402                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_RECTANGLE);
2403                 PY_DICT_ADD_INT(GL_R16_SNORM);
2404                 PY_DICT_ADD_INT(GL_R8_SNORM);
2405                 PY_DICT_ADD_INT(GL_RG16_SNORM);
2406                 PY_DICT_ADD_INT(GL_RG8_SNORM);
2407                 PY_DICT_ADD_INT(GL_RGB16_SNORM);
2408                 PY_DICT_ADD_INT(GL_RGB8_SNORM);
2409                 PY_DICT_ADD_INT(GL_RGBA16_SNORM);
2410                 PY_DICT_ADD_INT(GL_RGBA8_SNORM);
2411                 PY_DICT_ADD_INT(GL_SAMPLER_2D_RECT);
2412                 PY_DICT_ADD_INT(GL_SAMPLER_2D_RECT_SHADOW);
2413                 PY_DICT_ADD_INT(GL_SAMPLER_BUFFER);
2414                 PY_DICT_ADD_INT(GL_SIGNED_NORMALIZED);
2415                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_BUFFER);
2416                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_RECTANGLE);
2417                 PY_DICT_ADD_INT(GL_TEXTURE_BUFFER);
2418                 PY_DICT_ADD_INT(GL_TEXTURE_BUFFER_DATA_STORE_BINDING);
2419                 PY_DICT_ADD_INT(GL_TEXTURE_RECTANGLE);
2420                 PY_DICT_ADD_INT(GL_UNIFORM_ARRAY_STRIDE);
2421                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS);
2422                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);
2423                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_BINDING);
2424                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_DATA_SIZE);
2425                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_INDEX);
2426                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_NAME_LENGTH);
2427                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER);
2428                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER);
2429                 PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER);
2430                 PY_DICT_ADD_INT(GL_UNIFORM_BUFFER);
2431                 PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_BINDING);
2432                 PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT);
2433                 PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_SIZE);
2434                 PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_START);
2435                 PY_DICT_ADD_INT(GL_UNIFORM_IS_ROW_MAJOR);
2436                 PY_DICT_ADD_INT(GL_UNIFORM_MATRIX_STRIDE);
2437                 PY_DICT_ADD_INT(GL_UNIFORM_NAME_LENGTH);
2438                 PY_DICT_ADD_INT(GL_UNIFORM_OFFSET);
2439                 PY_DICT_ADD_INT(GL_UNIFORM_SIZE);
2440                 PY_DICT_ADD_INT(GL_UNIFORM_TYPE);
2441                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_RECT);
2442                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_BUFFER);
2443         }
2444
2445         /* GL_VERSION_3_2 */
2446         {
2447                 PY_DICT_ADD_INT(GL_ALREADY_SIGNALED);
2448                 PY_DICT_ADD_INT(GL_CONDITION_SATISFIED);
2449                 PY_DICT_ADD_INT(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT);
2450                 PY_DICT_ADD_INT(GL_CONTEXT_CORE_PROFILE_BIT);
2451                 PY_DICT_ADD_INT(GL_CONTEXT_PROFILE_MASK);
2452                 PY_DICT_ADD_INT(GL_DEPTH_CLAMP);
2453                 PY_DICT_ADD_INT(GL_FIRST_VERTEX_CONVENTION);
2454                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_LAYERED);
2455                 PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS);
2456                 PY_DICT_ADD_INT(GL_GEOMETRY_INPUT_TYPE);
2457                 PY_DICT_ADD_INT(GL_GEOMETRY_OUTPUT_TYPE);
2458                 PY_DICT_ADD_INT(GL_GEOMETRY_SHADER);
2459                 PY_DICT_ADD_INT(GL_GEOMETRY_VERTICES_OUT);
2460                 PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_MULTISAMPLE);
2461                 PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY);
2462                 PY_DICT_ADD_INT(GL_LAST_VERTEX_CONVENTION);
2463                 PY_DICT_ADD_INT(GL_LINES_ADJACENCY);
2464                 PY_DICT_ADD_INT(GL_LINE_STRIP_ADJACENCY);
2465                 PY_DICT_ADD_INT(GL_MAX_COLOR_TEXTURE_SAMPLES);
2466                 PY_DICT_ADD_INT(GL_MAX_DEPTH_TEXTURE_SAMPLES);
2467                 PY_DICT_ADD_INT(GL_MAX_FRAGMENT_INPUT_COMPONENTS);
2468                 PY_DICT_ADD_INT(GL_MAX_GEOMETRY_INPUT_COMPONENTS);
2469                 PY_DICT_ADD_INT(GL_MAX_GEOMETRY_OUTPUT_COMPONENTS);
2470                 PY_DICT_ADD_INT(GL_MAX_GEOMETRY_OUTPUT_VERTICES);
2471                 PY_DICT_ADD_INT(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS);
2472                 PY_DICT_ADD_INT(GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS);
2473                 PY_DICT_ADD_INT(GL_MAX_GEOMETRY_UNIFORM_COMPONENTS);
2474                 PY_DICT_ADD_INT(GL_MAX_INTEGER_SAMPLES);
2475                 PY_DICT_ADD_INT(GL_MAX_SAMPLE_MASK_WORDS);
2476                 PY_DICT_ADD_INT(GL_MAX_SERVER_WAIT_TIMEOUT);
2477                 PY_DICT_ADD_INT(GL_MAX_VERTEX_OUTPUT_COMPONENTS);
2478                 PY_DICT_ADD_INT(GL_OBJECT_TYPE);
2479                 PY_DICT_ADD_INT(GL_PROGRAM_POINT_SIZE);
2480                 PY_DICT_ADD_INT(GL_PROVOKING_VERTEX);
2481                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_MULTISAMPLE);
2482                 PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY);
2483                 PY_DICT_ADD_INT(GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
2484                 PY_DICT_ADD_INT(GL_SAMPLER_2D_MULTISAMPLE);
2485                 PY_DICT_ADD_INT(GL_SAMPLER_2D_MULTISAMPLE_ARRAY);
2486                 PY_DICT_ADD_INT(GL_SAMPLE_MASK);
2487                 PY_DICT_ADD_INT(GL_SAMPLE_MASK_VALUE);
2488                 PY_DICT_ADD_INT(GL_SAMPLE_POSITION);
2489                 PY_DICT_ADD_INT(GL_SIGNALED);
2490                 PY_DICT_ADD_INT(GL_SYNC_CONDITION);
2491                 PY_DICT_ADD_INT(GL_SYNC_FENCE);
2492                 PY_DICT_ADD_INT(GL_SYNC_FLAGS);
2493                 PY_DICT_ADD_INT(GL_SYNC_FLUSH_COMMANDS_BIT);
2494                 PY_DICT_ADD_INT(GL_SYNC_GPU_COMMANDS_COMPLETE);
2495                 PY_DICT_ADD_INT(GL_SYNC_STATUS);
2496                 PY_DICT_ADD_INT(GL_TEXTURE_2D_MULTISAMPLE);
2497                 PY_DICT_ADD_INT(GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
2498                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_MULTISAMPLE);
2499                 PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY);
2500                 PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_SEAMLESS);
2501                 PY_DICT_ADD_INT(GL_TEXTURE_FIXED_SAMPLE_LOCATIONS);
2502                 PY_DICT_ADD_INT(GL_TEXTURE_SAMPLES);
2503                 PY_DICT_ADD_INT(GL_TIMEOUT_EXPIRED);
2504                 PY_DICT_ADD_INT64(GL_TIMEOUT_IGNORED);
2505                 PY_DICT_ADD_INT(GL_TRIANGLES_ADJACENCY);
2506                 PY_DICT_ADD_INT(GL_TRIANGLE_STRIP_ADJACENCY);
2507                 PY_DICT_ADD_INT(GL_UNSIGNALED);
2508                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE);
2509                 PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY);
2510                 PY_DICT_ADD_INT(GL_WAIT_FAILED);
2511         }
2512
2513         /* GL_VERSION_3_3 */
2514         {
2515                 PY_DICT_ADD_INT(GL_ANY_SAMPLES_PASSED);
2516                 PY_DICT_ADD_INT(GL_INT_2_10_10_10_REV);
2517                 PY_DICT_ADD_INT(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS);
2518                 PY_DICT_ADD_INT(GL_ONE_MINUS_SRC1_ALPHA);
2519                 PY_DICT_ADD_INT(GL_ONE_MINUS_SRC1_COLOR);
2520                 PY_DICT_ADD_INT(GL_RGB10_A2UI);
2521                 PY_DICT_ADD_INT(GL_SAMPLER_BINDING);
2522                 PY_DICT_ADD_INT(GL_SRC1_COLOR);
2523                 PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_A);
2524                 PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_B);
2525                 PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_G);
2526                 PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_R);
2527                 PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_RGBA);
2528                 PY_DICT_ADD_INT(GL_TIMESTAMP);
2529                 PY_DICT_ADD_INT(GL_TIME_ELAPSED);
2530                 PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR);
2531         }
2532
2533         return submodule;
2534 }
2535
2536 static PyObject *Method_ShaderSource(PyObject *UNUSED(self), PyObject *args)
2537 {
2538         unsigned int shader;
2539         const char *source;
2540
2541         if (!PyArg_ParseTuple(args, "Is", &shader, &source))
2542                 return NULL;
2543
2544         glShaderSource(shader, 1, (const char **)&source, NULL);
2545
2546         Py_RETURN_NONE;
2547 }
2548
2549
2550 /** \} */