from stdapi import *
-GLboolean = Alias("GLboolean", Bool)
+GLboolean = Enum("GLboolean", [
+ "GL_TRUE",
+ "GL_FALSE",
+])
+
GLvoid = Alias("GLvoid", Void)
GLbyte = Alias("GLbyte", SChar)
GLshort = Alias("GLshort", Short)
GLclampf = Alias("GLclampf", Float)
GLdouble = Alias("GLdouble", Double)
GLclampd = Alias("GLclampd", Double)
-GLchar = Alias("GLchar", SChar)
-GLstring = String("GLchar *")
+GLchar = Alias("GLchar", Char)
GLcharARB = Alias("GLcharARB", SChar)
-GLstringARB = String("GLcharARB *")
GLintptrARB = Alias("GLintptrARB", Int)
GLsizeiptrARB = Alias("GLsizeiptrARB", Int)
GLhandleARB = Handle("handleARB", Alias("GLhandleARB", UInt))
GLhalfNV = Alias("GLhalfNV", UShort)
GLint64EXT = Alias("GLint64EXT", Int64)
GLuint64EXT = Alias("GLuint64EXT", UInt64)
+GLDEBUGPROC = Opaque("GLDEBUGPROC")
GLDEBUGPROCARB = Opaque("GLDEBUGPROCARB")
GLDEBUGPROCAMD = Opaque("GLDEBUGPROCAMD")
+GLstring = String(GLchar)
+GLstringConst = String(Const(GLchar))
+GLstringARB = String(GLcharARB)
+GLstringConstARB = String(Const(GLcharARB))
+
GLpointer = OpaquePointer(GLvoid)
GLpointerConst = OpaquePointer(Const(GLvoid))
GLfenceNV = Handle("fenceNV", GLuint)
GLprogram = Handle("program", GLuint)
GLshader = Handle("shader", GLuint)
-GLlocation = Handle("location", GLint, key=('program', GLuint))
-GLlocationARB = Handle("locationARB", GLint, key=('programObj', GLhandleARB))
+
+# Share the same mapping table for uniform locations of both core and
+# GL_ARB_shader_objects programs. For a combination of reasons:
+#
+# - all OpenGL implementations appear to alias the names for both kind of
+# programs;
+#
+# - most applications will use only one kind of shader programs;
+#
+# - some applications actually mix glUniformXxx calls with
+# GL_ARB_shader_objects programs and glUniformXxxARB calls with core
+# programs, and therefore, rely on a joint implementation.
+#
+# We use GLhandleARB as program key, since it is wider (void *) on MacOSX.
+#
+GLlocation = Handle("location", GLint, key=('program', GLhandleARB))
+GLlocationARB = Handle("location", GLint, key=('programObj', GLhandleARB))
+
+contextKey = ('reinterpret_cast<uintptr_t>(glretrace::getCurrentContext())', UIntPtr)
+
GLprogramARB = Handle("programARB", GLuint)
GLframebuffer = Handle("framebuffer", GLuint)
GLrenderbuffer = Handle("renderbuffer", GLuint)
GLfragmentShaderATI = Handle("fragmentShaderATI", GLuint)
-GLarray = Handle("array", GLuint)
+GLarray = Handle("array", GLuint, key=contextKey) # per-context
+GLarrayAPPLE = Handle("arrayAPPLE", GLuint) # shared
GLregion = Handle("region", GLuint)
-GLmap = Handle("map", GLpointer)
GLpipeline = Handle("pipeline", GLuint)
GLsampler = Handle("sampler", GLuint)
GLfeedback = Handle("feedback", GLuint)
+GLfence = Handle("fence", GLuint)
+
+# GL mappings are pointers to linear memory regions.
+#
+# The map length is not always available in the function prototype, and must be
+# reconstructed from other state.
+GLmap = LinearPointer(GLvoid, "length")
-GLsync_ = Opaque("GLsync")
-GLsync = Handle("sync", GLsync_)
+GLsync = Handle("sync", IntPointer("GLsync"))
GLenum = Enum("GLenum", [
# Parameters are added later from glparams.py's parameter table
])
# Some functions take GLenum disguised as GLint, and need special treatment so
-# that symbolic names are traced correctly. Apple noticed and fixed it in the
-# gl.h header, which further complicates things. C++ typechecking rules force
-# the wrappers to match the prototype precisely, so the precise type is defined
-# in glimports.hpp
-GLenum_int = Alias("GLenum_int", GLenum)
+# that symbolic names are traced correctly.
+GLenum_int = Alias("GLint", GLenum)
GLenum_mode = FakeEnum(GLenum, [
"GL_POINTS", # 0x0000
"GL_GEOMETRY_SHADER_BIT", # 0x00000004
"GL_TESS_CONTROL_SHADER_BIT", # 0x00000008
"GL_TESS_EVALUATION_SHADER_BIT", # 0x00000010
+ "GL_COMPUTE_SHADER_BIT", # 0x00000020
])
GLbitfield_access = Flags(GLbitfield, [
"GL_ATOMIC_COUNTER_BARRIER_BIT", # 0x00001000
])
+# GL_ARB_vertex_array_bgra
+size_bgra = FakeEnum(GLint, [
+ "GL_BGRA",
+])
+
+
+def GLindexBuffer(countExpr, typeExpr):
+ # Indices arguments are polymorphic:
+ # - offsets when element array buffer is bound
+ # - or a blob otherwise.
+ sizeExpr = '%s*_gl_type_size(%s)' % (countExpr, typeExpr)
+ return Polymorphic('_element_array_buffer_binding()', [
+ ('0', Blob(Const(GLvoid), sizeExpr)),
+ ],
+ IntPointer("const GLvoid *"),
+ contextLess=False,
+ )
+
+# Polymorphic object name
+def GLname(targetExpr):
+ return Polymorphic(targetExpr, [
+ ('GL_BUFFER', GLbuffer),
+ ('GL_SHADER', GLshader),
+ ('GL_PROGRAM', GLprogram),
+ ('GL_VERTEX_ARRAY', GLarray),
+ ('GL_QUERY', GLquery),
+ ('GL_PROGRAM_PIPELINE', GLpipeline),
+ ('GL_TRANSFORM_FEEDBACK', GLuint),
+ ('GL_SAMPLER', GLsampler),
+ ('GL_TEXTURE', GLtexture),
+ ('GL_TEXTURE_1D', GLtexture),
+ ('GL_TEXTURE_1D_ARRAY', GLtexture),
+ ('GL_TEXTURE_2D', GLtexture),
+ ('GL_TEXTURE_2D_MULTISAMPLE', GLtexture),
+ ('GL_TEXTURE_2D_ARRAY', GLtexture),
+ ('GL_TEXTURE_RECTANGLE', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP_POSITIVE_X', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP_NEGATIVE_X', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP_POSITIVE_Y', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP_NEGATIVE_Y', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP_POSITIVE_Z', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP_NEGATIVE_Z', GLtexture),
+ ('GL_TEXTURE_CUBE_MAP_ARRAY', GLtexture),
+ ('GL_TEXTURE_3D', GLtexture),
+ ('GL_RENDERBUFFER', GLrenderbuffer),
+ ('GL_FRAMEBUFFER', GLframebuffer),
+ ('GL_DISPLAY_LIST', GLlist),
+ ('GL_FENCE_APPLE', GLfence),
+ ('GL_DRAW_PIXELS_APPLE', GLuint), # GL_APPLE_fence
+ ], GLuint)
+
+
+# GL_AMD_performance_monitor
+GLperfMonitorCounterInfoAMD = Polymorphic('pname', [
+ ('GL_COUNTER_TYPE_AMD', Pointer(GLenum)),
+ ('GL_PERCENTAGE_AMD', Pointer(Float)),
+ ('GL_COUNTER_RANGE_AMD', Array(Float, 2)),
+ ],
+ OpaquePointer(GLvoid),
+)