1from OpenGL import arrays 2from OpenGL.raw.GL._types import GLenum,GLboolean,GLsizei,GLint,GLuint 3from OpenGL.raw.osmesa._types import * 4from OpenGL.constant import Constant as _C 5from OpenGL import platform as _p 6import ctypes 7 8def _f( function ): 9 return _p.createFunction( 10 function,_p.PLATFORM.OSMesa, 11 None, 12 error_checker=None 13 ) 14 15OSMESA_COLOR_INDEX = _C('OSMESA_COLOR_INDEX', 6400) 16OSMESA_RGBA = _C('OSMESA_RGBA', 6408) 17OSMESA_BGRA = _C('OSMESA_BGRA', 0x1) 18OSMESA_ARGB = _C('OSMESA_ARGB', 0x2) 19OSMESA_RGB = _C('OSMESA_RGB', 6407) 20OSMESA_BGR = _C('OSMESA_BGR', 0x4) 21OSMESA_RGB_565 = _C('OSMESA_BGR', 0x5) 22OSMESA_ROW_LENGTH = _C('OSMESA_ROW_LENGTH', 0x10) 23OSMESA_Y_UP = _C('OSMESA_Y_UP', 0x11) 24OSMESA_WIDTH = _C('OSMESA_WIDTH', 0x20) 25OSMESA_HEIGHT = _C('OSMESA_HEIGHT', 0x21) 26OSMESA_FORMAT = _C('OSMESA_FORMAT', 0x22) 27OSMESA_TYPE = _C('OSMESA_TYPE', 0x23) 28OSMESA_MAX_WIDTH = _C('OSMESA_MAX_WIDTH', 0x24) 29OSMESA_MAX_HEIGHT = _C('OSMESA_MAX_HEIGHT', 0x25) 30OSMESA_DEPTH_BITS = _C('OSMESA_DEPTH_BITS', 0x30) 31OSMESA_STENCIL_BITS = _C('OSMESA_STENCIL_BITS', 0x31) 32OSMESA_ACCUM_BITS = _C('OSMESA_ACCUM_BITS', 0x32) 33OSMESA_PROFILE = _C('OSMESA_PROFILE', 0x33) 34OSMESA_CORE_PROFILE = _C('OSMESA_CORE_PROFILE', 0x34) 35OSMESA_COMPAT_PROFILE = _C('OSMESA_CORE_PROFILE', 0x35) 36OSMESA_CONTEXT_MAJOR_VERSION = _C('OSMESA_CONTEXT_MAJOR_VERSION', 0x36) 37OSMESA_CONTEXT_MINOR_VERSION = _C('OSMESA_CONTEXT_MINOR_VERSION', 0x37) 38 39OSMesaGetCurrentContext = _p.GetCurrentContext 40 41@_f 42@_p.types(OSMesaContext,GLenum, OSMesaContext) 43def OSMesaCreateContext(format,sharelist): pass 44 45@_f 46@_p.types(OSMesaContext,GLenum, GLint, GLint, GLint, OSMesaContext) 47def OSMesaCreateContextExt(format, depthBits, stencilBits,accumBits,sharelist ): pass 48 49@_f 50@_p.types(OSMesaContext,arrays.GLintArray, OSMesaContext) 51def OSMesaCreateContextAttribs(attribList,sharelist ): pass 52 53@_f 54@_p.types(None, OSMesaContext) 55def OSMesaDestroyContext(ctx): pass 56 57@_f 58@_p.types(GLboolean, OSMesaContext, ctypes.POINTER(None), GLenum, GLsizei, GLsizei ) 59def OSMesaMakeCurrent( ctx, buffer, type,width,height ): pass 60 61@_f 62@_p.types(None, GLint, GLint ) 63def OSMesaPixelStore( ctx, buffer, type,width,height ): pass 64 65def OSMesaGetIntegerv(pname): 66 value = GLint() 67 _p.PLATFORM.GL.OSMesaGetIntegerv(pname, ctypes.byref(value)) 68 return value.value 69 70def OSMesaGetDepthBuffer(c): 71 width, height, bytesPerValue = GLint(), GLint(), GLint() 72 buffer = ctypes.POINTER(GLint)() 73 74 if _p.PLATFORM.GL.OSMesaGetDepthBuffer(c, ctypes.byref(width), 75 ctypes.byref(height), 76 ctypes.byref(bytesPerValue), 77 ctypes.byref(buffer)): 78 return width.value, height.value, bytesPerValue.value, buffer 79 else: 80 return 0, 0, 0, None 81 82def OSMesaGetColorBuffer(c): 83 # TODO: make output array types which can handle the operation 84 # provide an API to convert pointers + sizes to array instances, 85 # e.g. numpy.ctypeslib.as_array( ptr, bytesize ).astype( 'B' ).reshape( height,width ) 86 width, height, format = GLint(), GLint(), GLint() 87 buffer = ctypes.c_void_p() 88 89 if _p.PLATFORM.GL.OSMesaGetColorBuffer(c, ctypes.byref(width), 90 ctypes.byref(height), 91 ctypes.byref(format), 92 ctypes.byref(buffer)): 93 return width.value, height.value, format.value, buffer 94 else: 95 return 0, 0, 0, None 96 97@_f 98@_p.types(GLboolean) 99def OSMesaColorClamp(enable): 100 """Enable/disable color clamping, off by default 101 102 New in Mesa 6.4.2 103 """ 104 105@_f 106@_p.types(OSMesaContext, arrays.GLcharArray, GLuint) 107def OSMesaPostprocess(osmesa, filter, enable_value): 108 """Enable/disable Gallium post-process filters. 109 110 This should be called after a context is created, but before it is 111 made current for the first time. After a context has been made 112 current, this function has no effect. 113 114 If the enable_value param is zero, the filter is disabled. Otherwise 115 the filter is enabled, and the value may control the filter's quality. 116 New in Mesa 10.0 117 """ 118 119 120__all__ = [ 121 'OSMesaCreateContext', 122 'OSMesaCreateContextExt', 'OSMesaMakeCurrent', 'OSMesaGetIntegerv', 123 'OSMesaGetCurrentContext', 'OSMesaDestroyContext', 'OSMesaPixelStore', 124 'OSMesaGetDepthBuffer', 'OSMesaGetColorBuffer', 'OSMesaCreateContextAttribs', 125 'OSMesaColorClamp','OSMesaPostprocess', 126 'OSMESA_COLOR_INDEX', 'OSMESA_RGBA', 'OSMESA_BGRA', 'OSMESA_ARGB', 127 'OSMESA_RGB', 'OSMESA_BGR', 'OSMESA_BGR', 'OSMESA_ROW_LENGTH', 128 'OSMESA_Y_UP', 'OSMESA_WIDTH', 'OSMESA_HEIGHT', 'OSMESA_FORMAT', 129 'OSMESA_TYPE', 'OSMESA_MAX_WIDTH', 'OSMESA_MAX_HEIGHT', 130 'OSMESA_DEPTH_BITS', 'OSMESA_STENCIL_BITS', 'OSMESA_ACCUM_BITS', 131 'OSMESA_PROFILE', 'OSMESA_CORE_PROFILE', 'OSMESA_COMPAT_PROFILE', 132 'OSMESA_CONTEXT_MAJOR_VERSION', 'OSMESA_CONTEXT_MINOR_VERSION' 133] 134