]> git.cworth.org Git - apitrace/blob - cglapi.py
Bundle Snappy source code.
[apitrace] / cglapi.py
1 ##########################################################################
2 #
3 # Copyright 2008-2009 VMware, Inc.
4 # All Rights Reserved.
5 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
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
22 # THE SOFTWARE.
23 #
24 ##########################################################################/
25
26 """CGL API description."""
27
28
29 from stdapi import *
30 from glapi import *
31 from glapi import glapi
32
33 IOSurfaceRef = Opaque("IOSurfaceRef")
34 CGLContextObj = Opaque("CGLContextObj")
35 CGLPixelFormatObj = Opaque("CGLPixelFormatObj")
36 CGLRendererInfoObj = Opaque("CGLRendererInfoObj")
37 CGLPBufferObj = Opaque("CGLPBufferObj")
38 CGLShareGroup = Opaque("CGLShareGroup")
39 CGLShareGroupObj = Opaque("CGLShareGroupObj")
40 CGSConnectionID = Alias("CGSConnectionID", Int)
41 CGSWindowID = Alias("CGSWindowID", Int)
42 CGSSurfaceID = Alias("CGSSurfaceID", Int)
43
44 CGLPixelFormatAttribute = Enum("CGLPixelFormatAttribute", [
45     "kCGLPFAAllRenderers",
46     "kCGLPFADoubleBuffer",
47     "kCGLPFAStereo",
48     "kCGLPFAAuxBuffers",
49     "kCGLPFAColorSize",
50     "kCGLPFAAlphaSize",
51     "kCGLPFADepthSize",
52     "kCGLPFAStencilSize",
53     "kCGLPFAAccumSize",
54     "kCGLPFAMinimumPolicy",
55     "kCGLPFAMaximumPolicy",
56     "kCGLPFAOffScreen",
57     "kCGLPFAFullScreen",
58     "kCGLPFASampleBuffers",
59     "kCGLPFASamples",
60     "kCGLPFAAuxDepthStencil",
61     "kCGLPFAColorFloat",
62     "kCGLPFAMultisample",
63     "kCGLPFASupersample",
64     "kCGLPFASampleAlpha",
65     "kCGLPFARendererID",
66     "kCGLPFASingleRenderer",
67     "kCGLPFANoRecovery",
68     "kCGLPFAAccelerated",
69     "kCGLPFAClosestPolicy",
70     "kCGLPFABackingStore",
71     "kCGLPFAWindow",
72     "kCGLPFACompliant",
73     "kCGLPFADisplayMask",
74     "kCGLPFAPBuffer",
75     "kCGLPFARemotePBuffer",
76     "kCGLPFAAllowOfflineRenderers",
77     "kCGLPFAAcceleratedCompute",
78     "kCGLPFAVirtualScreenCount",
79     "kCGLPFARobust",
80     "kCGLPFAMPSafe",
81     "kCGLPFAMultiScreen",
82 ])
83
84 CGLRendererProperty = Enum("CGLRendererProperty", [
85     "kCGLRPOffScreen",
86     "kCGLRPFullScreen",
87     "kCGLRPRendererID",
88     "kCGLRPAccelerated",
89     "kCGLRPRobust",
90     "kCGLRPBackingStore",
91     "kCGLRPMPSafe",
92     "kCGLRPWindow",
93     "kCGLRPMultiScreen",
94     "kCGLRPCompliant",
95     "kCGLRPDisplayMask",
96     "kCGLRPBufferModes",
97     "kCGLRPColorModes",
98     "kCGLRPAccumModes",
99     "kCGLRPDepthModes",
100     "kCGLRPStencilModes",
101     "kCGLRPMaxAuxBuffers",
102     "kCGLRPMaxSampleBuffers",
103     "kCGLRPMaxSamples",
104     "kCGLRPSampleModes",
105     "kCGLRPSampleAlpha",
106     "kCGLRPVideoMemory",
107     "kCGLRPTextureMemory",
108     "kCGLRPGPUVertProcCapable",
109     "kCGLRPGPUFragProcCapable",
110     "kCGLRPRendererCount",
111     "kCGLRPOnline",
112     "kCGLRPAcceleratedCompute",
113 ])
114
115 CGLContextEnable = Enum("CGLContextEnable", [
116     "kCGLCESwapRectangle",
117     "kCGLCESwapLimit",
118     "kCGLCERasterization",
119     "kCGLCEStateValidation",
120     "kCGLCESurfaceBackingSize",
121     "kCGLCEDisplayListOptimization",
122     "kCGLCEMPEngine",
123 ])
124
125 CGLContextParameter = Enum("CGLContextParameter", [
126     "kCGLCPSwapRectangle",
127     "kCGLCPSwapInterval",
128     "kCGLCPDispatchTableSize",
129     "kCGLCPClientStorage",
130     "kCGLCPSurfaceTexture",
131     "kCGLCPSurfaceOrder",
132     "kCGLCPSurfaceOpacity",
133     "kCGLCPSurfaceBackingSize",
134     "kCGLCPSurfaceSurfaceVolatile",
135     "kCGLCPReclaimResources",
136     "kCGLCPCurrentRendererID",
137     "kCGLCPGPUVertexProcessing",
138     "kCGLCPGPUFragmentProcessing",
139     "kCGLCPHasDrawable",
140     "kCGLCPMPSwapsInFlight",
141 ])
142
143 CGLGlobalOption = Enum("CGLGlobalOption", [
144     "kCGLGOFormatCacheSize",
145     "kCGLGOClearFormatCache",
146     "kCGLGORetainRenderers",
147     "kCGLGOResetLibrary",
148     "kCGLGOUseErrorHandler",
149     "kCGLGOUseBuildCache",
150 ])
151
152 CGLError = Enum("CGLError", [
153     "kCGLNoError",
154     "kCGLBadAttribute",
155     "kCGLBadProperty",
156     "kCGLBadPixelFormat",
157     "kCGLBadRendererInfo",
158     "kCGLBadContext",
159     "kCGLBadDrawable",
160     "kCGLBadDisplay",
161     "kCGLBadState",
162     "kCGLBadValue",
163     "kCGLBadMatch",
164     "kCGLBadEnumeration",
165     "kCGLBadOffScreen",
166     "kCGLBadFullScreen",
167     "kCGLBadWindow",
168     "kCGLBadAddress",
169     "kCGLBadCodeModule",
170     "kCGLBadAlloc",
171     "kCGLBadConnection",
172 ])
173
174 CGLContextObj = Opaque("CGLContextObj")
175
176 cglapi = API("CGL")
177
178 cglapi.add_functions([
179     # CGLCurrent.h, libGL.dylib
180     Function(CGLError, "CGLSetCurrentContext", [(CGLContextObj, "ctx")]),
181     Function(CGLContextObj, "CGLGetCurrentContext", []),
182
183     # OpenGL.h, OpenGL framework
184     Function(CGLError, "CGLChoosePixelFormat", [(Const(OpaquePointer(CGLPixelFormatAttribute)), "attribs"), (OpaquePointer(CGLPixelFormatObj), "pix"), (OpaquePointer(GLint), "npix")]),
185     Function(CGLError, "CGLDestroyPixelFormat", [(CGLPixelFormatObj, "pix")]),
186     Function(CGLError, "CGLDescribePixelFormat", [(CGLPixelFormatObj, "pix"), (GLint, "pix_num"), (CGLPixelFormatAttribute, "attrib"), (OpaquePointer(GLint), "value")]),
187     Function(Void, "CGLReleasePixelFormat", [(CGLPixelFormatObj, "pix")]),
188     Function(CGLPixelFormatObj, "CGLRetainPixelFormat", [(CGLPixelFormatObj, "pix")]),
189     Function(GLuint, "CGLGetPixelFormatRetainCount", [(CGLPixelFormatObj, "pix")]),
190     Function(CGLError, "CGLQueryRendererInfo", [(GLuint, "display_mask"), (OpaquePointer(CGLRendererInfoObj), "rend"), (OpaquePointer(GLint), "nrend")]),
191     Function(CGLError, "CGLDestroyRendererInfo", [(CGLRendererInfoObj, "rend")]),
192     Function(CGLError, "CGLDescribeRenderer", [(CGLRendererInfoObj, "rend"), (GLint, "rend_num"), (CGLRendererProperty, "prop"), (OpaquePointer(GLint), "value")]),
193     Function(CGLError, "CGLCreateContext", [(CGLPixelFormatObj, "pix"), (CGLContextObj, "share"), (OpaquePointer(CGLContextObj), "ctx")]),
194     Function(CGLError, "CGLDestroyContext", [(CGLContextObj, "ctx")]),
195     Function(CGLError, "CGLCopyContext", [(CGLContextObj, "src"), (CGLContextObj, "dst"), (GLbitfield, "mask")]),
196     Function(CGLContextObj, "CGLRetainContext", [(CGLContextObj, "ctx")]),
197     Function(Void, "CGLReleaseContext", [(CGLContextObj, "ctx")]),
198     Function(GLuint, "CGLGetContextRetainCount", [(CGLContextObj, "ctx")]),
199     Function(CGLPixelFormatObj, "CGLGetPixelFormat", [(CGLContextObj, "ctx")]),
200     Function(CGLError, "CGLCreatePBuffer", [(GLsizei, "width"), (GLsizei, "height"), (GLenum, "target"), (GLenum, "internalFormat"), (GLint, "max_level"), (OpaquePointer(CGLPBufferObj), "pbuffer")]),
201     Function(CGLError, "CGLDestroyPBuffer", [(CGLPBufferObj, "pbuffer")]),
202     Function(CGLError, "CGLDescribePBuffer", [(CGLPBufferObj, "obj"), (OpaquePointer(GLsizei), "width"), (OpaquePointer(GLsizei), "height"), (OpaquePointer(GLenum), "target"), (OpaquePointer(GLenum), "internalFormat"), (OpaquePointer(GLint), "mipmap")]),
203     Function(CGLError, "CGLTexImagePBuffer", [(CGLContextObj, "ctx"), (CGLPBufferObj, "pbuffer"), (GLenum, "source")]),
204     Function(CGLPBufferObj, "CGLRetainPBuffer", [(CGLPBufferObj, "pbuffer")]),
205     Function(Void, "CGLReleasePBuffer", [(CGLPBufferObj, "pbuffer")]),
206     Function(GLuint, "CGLGetPBufferRetainCount", [(CGLPBufferObj, "pbuffer")]),
207     Function(CGLError, "CGLSetOffScreen", [(CGLContextObj, "ctx"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "rowbytes"), (OpaquePointer(Void), "baseaddr")]),
208     Function(CGLError, "CGLGetOffScreen", [(CGLContextObj, "ctx"), (OpaquePointer(GLsizei), "width"), (OpaquePointer(GLsizei), "height"), (OpaquePointer(GLint), "rowbytes"), (OpaquePointer(OpaquePointer(Void)), "baseaddr")]),
209     Function(CGLError, "CGLSetFullScreen", [(CGLContextObj, "ctx")]),
210     Function(CGLError, "CGLSetFullScreenOnDisplay", [(CGLContextObj, "ctx"), (GLuint, "display_mask")]),
211     Function(CGLError, "CGLSetPBuffer", [(CGLContextObj, "ctx"), (CGLPBufferObj, "pbuffer"), (GLenum, "face"), (GLint, "level"), (GLint, "screen")]),
212     Function(CGLError, "CGLGetPBuffer", [(CGLContextObj, "ctx"), (OpaquePointer(CGLPBufferObj), "pbuffer"), (OpaquePointer(GLenum), "face"), (OpaquePointer(GLint), "level"), (OpaquePointer(GLint), "screen")]),
213     Function(CGLError, "CGLClearDrawable", [(CGLContextObj, "ctx")]),
214     Function(CGLError, "CGLFlushDrawable", [(CGLContextObj, "ctx")]),
215     Function(CGLError, "CGLEnable", [(CGLContextObj, "ctx"), (CGLContextEnable, "pname")]),
216     Function(CGLError, "CGLDisable", [(CGLContextObj, "ctx"), (CGLContextEnable, "pname")]),
217     Function(CGLError, "CGLIsEnabled", [(CGLContextObj, "ctx"), (CGLContextEnable, "pname"), (OpaquePointer(GLint), "enable")]),
218     Function(CGLError, "CGLSetParameter", [(CGLContextObj, "ctx"), (CGLContextParameter, "pname"), (Const(OpaquePointer(GLint)), "params")]),
219     Function(CGLError, "CGLGetParameter", [(CGLContextObj, "ctx"), (CGLContextParameter, "pname"), (OpaquePointer(GLint), "params")]),
220     Function(CGLError, "CGLSetVirtualScreen", [(CGLContextObj, "ctx"), (GLint, "screen")]),
221     Function(CGLError, "CGLGetVirtualScreen", [(CGLContextObj, "ctx"), (OpaquePointer(GLint), "screen")]),
222     Function(CGLError, "CGLSetGlobalOption", [(CGLGlobalOption, "pname"), (Const(OpaquePointer(GLint)), "params")]),
223     Function(CGLError, "CGLGetGlobalOption", [(CGLGlobalOption, "pname"), (OpaquePointer(GLint), "params")]),
224     Function(CGLError, "CGLSetOption", [(CGLGlobalOption, "pname"), (GLint, "param")]),
225     Function(CGLError, "CGLGetOption", [(CGLGlobalOption, "pname"), (OpaquePointer(GLint), "param")]),
226     Function(CGLError, "CGLLockContext", [(CGLContextObj, "ctx")]),
227     Function(CGLError, "CGLUnlockContext", [(CGLContextObj, "ctx")]),
228     Function(Void, "CGLGetVersion", [(OpaquePointer(GLint), "majorvers"), (OpaquePointer(GLint), "minorvers")]),
229     Function(Const(CString), "CGLErrorString", [(CGLError, "error")]),
230
231     # CGLIOSurface.h, OpenGL framework
232     Function(CGLError, "CGLTexImageIOSurface2D", [(CGLContextObj, "ctx"), (GLenum, "target"), (GLenum, "internal_format"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (IOSurfaceRef, "ioSurface"), (GLuint, "plane")]),
233
234     # CGLDevice.h, OpenGL framework
235     Function(CGLShareGroupObj, "CGLGetShareGroup", [(CGLContextObj, "ctx")]),
236
237     # Undocumented, OpenGL framework
238     Function(CGLError, "CGLSetSurface", [(CGLContextObj, "ctx"), (CGSConnectionID, "cid"), (CGSWindowID, "wid"), (CGSSurfaceID, "sid")]),
239     Function(CGLError, "CGLGetSurface", [(CGLContextObj, "ctx"), (OpaquePointer(CGSConnectionID), "cid"), (OpaquePointer(CGSWindowID), "wid"), (OpaquePointer(CGSSurfaceID), "sid")]),
240     Function(CGLError, "CGLUpdateContext", [(CGLContextObj, "ctx")]),
241     # XXX: Confirm CGLOpenCLMuxLockDown
242     Function(CGLError, "CGLOpenCLMuxLockDown", []),
243     # FIXME: CGLAreContextsShared
244     # FIXME: CGLBackDispatch
245     # FIXME: CGLFrontDispatch
246     # FIXME: CGLGetNextContext
247     # FIXME: CGLRestoreDispatch
248     # FIXME: CGLRestoreDispatchFunction
249     # FIXME: CGLSelectDispatch
250     # FIXME: CGLSelectDispatchBounded
251     # FIXME: CGLSelectDispatchFunction
252     # FIXME: CGLSetPBufferVolatileState
253 ])
254