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