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