1 ##########################################################################
3 # Copyright 2008-2009 VMware, Inc.
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 ##########################################################################/
26 """CGL API description."""
31 from glapi import glapi
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)
44 CGLPixelFormatAttribute = Enum("CGLPixelFormatAttribute", [
45 "kCGLPFAAllRenderers",
46 "kCGLPFADoubleBuffer",
54 "kCGLPFAMinimumPolicy",
55 "kCGLPFAMaximumPolicy",
58 "kCGLPFASampleBuffers",
60 "kCGLPFAAuxDepthStencil",
66 "kCGLPFASingleRenderer",
69 "kCGLPFAClosestPolicy",
70 "kCGLPFABackingStore",
75 "kCGLPFARemotePBuffer",
76 "kCGLPFAAllowOfflineRenderers",
77 "kCGLPFAAcceleratedCompute",
78 "kCGLPFAVirtualScreenCount",
84 CGLRendererProperty = Enum("CGLRendererProperty", [
100 "kCGLRPStencilModes",
101 "kCGLRPMaxAuxBuffers",
102 "kCGLRPMaxSampleBuffers",
107 "kCGLRPTextureMemory",
108 "kCGLRPGPUVertProcCapable",
109 "kCGLRPGPUFragProcCapable",
110 "kCGLRPRendererCount",
112 "kCGLRPAcceleratedCompute",
115 CGLContextEnable = Enum("CGLContextEnable", [
116 "kCGLCESwapRectangle",
118 "kCGLCERasterization",
119 "kCGLCEStateValidation",
120 "kCGLCESurfaceBackingSize",
121 "kCGLCEDisplayListOptimization",
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",
140 "kCGLCPMPSwapsInFlight",
143 CGLGlobalOption = Enum("CGLGlobalOption", [
144 "kCGLGOFormatCacheSize",
145 "kCGLGOClearFormatCache",
146 "kCGLGORetainRenderers",
147 "kCGLGOResetLibrary",
148 "kCGLGOUseErrorHandler",
149 "kCGLGOUseBuildCache",
152 CGLError = Enum("CGLError", [
156 "kCGLBadPixelFormat",
157 "kCGLBadRendererInfo",
164 "kCGLBadEnumeration",
174 CGLContextObj = Opaque("CGLContextObj")
178 cglapi.add_functions([
179 # CGLCurrent.h, libGL.dylib
180 Function(CGLError, "CGLSetCurrentContext", [(CGLContextObj, "ctx")]),
181 Function(CGLContextObj, "CGLGetCurrentContext", []),
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")]),
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")]),
234 # CGLDevice.h, OpenGL framework
235 Function(CGLShareGroupObj, "CGLGetShareGroup", [(CGLContextObj, "ctx")]),
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