1 ##########################################################################
3 # Copyright 2011 Jose Fonseca
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 ##########################################################################/
27 '''Describe GL types.'''
35 GLboolean = Alias("GLboolean", Bool)
36 GLvoid = Alias("GLvoid", Void)
37 GLbyte = Alias("GLbyte", SChar)
38 GLshort = Alias("GLshort", Short)
39 GLint = Alias("GLint", Int)
40 GLint64 = Alias("GLint64", Int64)
41 GLubyte = Alias("GLubyte", UChar)
42 GLushort = Alias("GLushort", UShort)
43 GLuint = Alias("GLuint", UInt)
44 GLuint64 = Alias("GLuint64", UInt64)
45 GLsizei = Alias("GLsizei", Int)
46 GLintptr = Alias("GLintptr", Int)
47 GLsizeiptr = Alias("GLsizeiptr", Int)
48 GLfloat = Alias("GLfloat", Float)
49 GLclampf = Alias("GLclampf", Float)
50 GLdouble = Alias("GLdouble", Double)
51 GLclampd = Alias("GLclampd", Double)
52 GLchar = Alias("GLchar", SChar)
53 GLstring = String("GLchar *")
55 GLcharARB = Alias("GLcharARB", SChar)
56 GLstringARB = String("GLcharARB *")
57 GLintptrARB = Alias("GLintptrARB", Int)
58 GLsizeiptrARB = Alias("GLsizeiptrARB", Int)
59 GLhandleARB = Handle("handleARB", Alias("GLhandleARB", UInt))
60 GLhalfARB = Alias("GLhalfARB", UShort)
61 GLhalfNV = Alias("GLhalfNV", UShort)
62 GLint64EXT = Alias("GLint64EXT", Int64)
63 GLuint64EXT = Alias("GLuint64EXT", UInt64)
64 GLDEBUGPROCARB = Opaque("GLDEBUGPROCARB")
65 GLDEBUGPROCAMD = Opaque("GLDEBUGPROCAMD")
67 GLpointer = OpaquePointer(GLvoid)
68 GLpointerConst = OpaquePointer(Const(GLvoid))
70 GLlist = Handle("list", GLuint)
71 GLtexture = Handle("texture", GLuint)
72 GLbuffer = Handle("buffer", GLuint)
73 GLquery = Handle("query", GLuint)
74 GLfenceNV = Handle("fenceNV", GLuint)
75 GLprogram = Handle("program", GLuint)
76 GLshader = Handle("shader", GLuint)
78 # Share the same mapping table for uniform locations of both core and
79 # GL_ARB_shader_objects programs. For a combination of reasons:
81 # - all OpenGL implementations appear to alias the names for both kind of
84 # - most applications will use only one kind of shader programs;
86 # - some applications actually mix glUniformXxx calls with
87 # GL_ARB_shader_objects programs and glUniformXxxARB calls with core
88 # programs, and therefore, rely on a joint implementation.
90 # We use GLhandleARB as program key, since it is wider (void *) on MacOSX.
92 GLlocation = Handle("location", GLint, key=('program', GLhandleARB))
93 GLlocationARB = Handle("location", GLint, key=('programObj', GLhandleARB))
95 GLprogramARB = Handle("programARB", GLuint)
96 GLframebuffer = Handle("framebuffer", GLuint)
97 GLrenderbuffer = Handle("renderbuffer", GLuint)
98 GLfragmentShaderATI = Handle("fragmentShaderATI", GLuint)
99 GLarray = Handle("array", GLuint)
100 GLregion = Handle("region", GLuint)
102 GLpipeline = Handle("pipeline", GLuint)
103 GLsampler = Handle("sampler", GLuint)
104 GLfeedback = Handle("feedback", GLuint)
106 GLsync_ = Opaque("GLsync")
107 GLsync = Handle("sync", GLsync_)
109 GLenum = Enum("GLenum", [
110 # Parameters are added later from glparams.py's parameter table
113 # Some functions take GLenum disguised as GLint, and need special treatment so
114 # that symbolic names are traced correctly. Apple noticed and fixed it in the
115 # gl.h header, which further complicates things. C++ typechecking rules force
116 # the wrappers to match the prototype precisely, so the precise type is defined
118 GLenum_int = Alias("GLenum_int", GLenum)
120 GLenum_mode = FakeEnum(GLenum, [
121 "GL_POINTS", # 0x0000
123 "GL_LINE_LOOP", # 0x0002
124 "GL_LINE_STRIP", # 0x0003
125 "GL_TRIANGLES", # 0x0004
126 "GL_TRIANGLE_STRIP", # 0x0005
127 "GL_TRIANGLE_FAN", # 0x0006
129 "GL_QUAD_STRIP", # 0x0008
130 "GL_POLYGON", # 0x0009
131 "GL_LINES_ADJACENCY", # 0x000A
132 "GL_LINE_STRIP_ADJACENCY", # 0x000B
133 "GL_TRIANGLES_ADJACENCY", # 0x000C
134 "GL_TRIANGLE_STRIP_ADJACENCY", # 0x000D
135 "GL_PATCHES", # 0x000E
138 GLenum_error = FakeEnum(GLenum, [
140 "GL_INVALID_ENUM", # 0x0500
141 "GL_INVALID_VALUE", # 0x0501
142 "GL_INVALID_OPERATION", # 0x0502
143 "GL_STACK_OVERFLOW", # 0x0503
144 "GL_STACK_UNDERFLOW", # 0x0504
145 "GL_OUT_OF_MEMORY", # 0x0505
146 "GL_INVALID_FRAMEBUFFER_OPERATION", # 0x0506
147 "GL_TABLE_TOO_LARGE", # 0x8031
150 GLbitfield = Alias("GLbitfield", UInt)
152 GLbitfield_attrib = Flags(GLbitfield, [
153 "GL_ALL_ATTRIB_BITS", # 0x000FFFFF
154 "GL_CURRENT_BIT", # 0x00000001
155 "GL_POINT_BIT", # 0x00000002
156 "GL_LINE_BIT", # 0x00000004
157 "GL_POLYGON_BIT", # 0x00000008
158 "GL_POLYGON_STIPPLE_BIT", # 0x00000010
159 "GL_PIXEL_MODE_BIT", # 0x00000020
160 "GL_LIGHTING_BIT", # 0x00000040
161 "GL_FOG_BIT", # 0x00000080
162 "GL_DEPTH_BUFFER_BIT", # 0x00000100
163 "GL_ACCUM_BUFFER_BIT", # 0x00000200
164 "GL_STENCIL_BUFFER_BIT", # 0x00000400
165 "GL_VIEWPORT_BIT", # 0x00000800
166 "GL_TRANSFORM_BIT", # 0x00001000
167 "GL_ENABLE_BIT", # 0x00002000
168 "GL_COLOR_BUFFER_BIT", # 0x00004000
169 "GL_HINT_BIT", # 0x00008000
170 "GL_EVAL_BIT", # 0x00010000
171 "GL_LIST_BIT", # 0x00020000
172 "GL_TEXTURE_BIT", # 0x00040000
173 "GL_SCISSOR_BIT", # 0x00080000
174 "GL_MULTISAMPLE_BIT", # 0x20000000
177 GLbitfield_client_attrib = Flags(GLbitfield, [
178 "GL_CLIENT_ALL_ATTRIB_BITS", # 0xFFFFFFFF
179 "GL_CLIENT_PIXEL_STORE_BIT", # 0x00000001
180 "GL_CLIENT_VERTEX_ARRAY_BIT", # 0x00000002
183 GLbitfield_shader = Flags(GLbitfield, [
184 "GL_ALL_SHADER_BITS", # 0xFFFFFFFF
185 "GL_VERTEX_SHADER_BIT", # 0x00000001
186 "GL_FRAGMENT_SHADER_BIT", # 0x00000002
187 "GL_GEOMETRY_SHADER_BIT", # 0x00000004
188 "GL_TESS_CONTROL_SHADER_BIT", # 0x00000008
189 "GL_TESS_EVALUATION_SHADER_BIT", # 0x00000010
192 GLbitfield_access = Flags(GLbitfield, [
193 "GL_MAP_READ_BIT", # 0x0001
194 "GL_MAP_WRITE_BIT", # 0x0002
195 "GL_MAP_INVALIDATE_RANGE_BIT", # 0x0004
196 "GL_MAP_INVALIDATE_BUFFER_BIT", # 0x0008
197 "GL_MAP_FLUSH_EXPLICIT_BIT", # 0x0010
198 "GL_MAP_UNSYNCHRONIZED_BIT", # 0x0020
201 GLbitfield_sync_flush = Flags(GLbitfield, [
202 "GL_SYNC_FLUSH_COMMANDS_BIT", # 0x00000001
205 GLbitfield_barrier = Flags(GLbitfield, [
206 "GL_ALL_BARRIER_BITS", # 0xFFFFFFFF
207 "GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT", # 0x00000001
208 "GL_ELEMENT_ARRAY_BARRIER_BIT", # 0x00000002
209 "GL_UNIFORM_BARRIER_BIT", # 0x00000004
210 "GL_TEXTURE_FETCH_BARRIER_BIT", # 0x00000008
211 "GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV", # 0x00000010
212 "GL_SHADER_IMAGE_ACCESS_BARRIER_BIT", # 0x00000020
213 "GL_COMMAND_BARRIER_BIT", # 0x00000040
214 "GL_PIXEL_BUFFER_BARRIER_BIT", # 0x00000080
215 "GL_TEXTURE_UPDATE_BARRIER_BIT", # 0x00000100
216 "GL_BUFFER_UPDATE_BARRIER_BIT", # 0x00000200
217 "GL_FRAMEBUFFER_BARRIER_BIT", # 0x00000400
218 "GL_TRANSFORM_FEEDBACK_BARRIER_BIT", # 0x00000800
219 "GL_ATOMIC_COUNTER_BARRIER_BIT", # 0x00001000