1 // osmesa-rs: Off-Screen Mesa bindings for Rust. 2 // The OSMesa library is available under the MIT license. 3 // These bindings are public domain. 4 5 #![allow(non_snake_case)] 6 7 #[macro_use] 8 extern crate shared_library; 9 10 use std::os::raw::{ 11 c_char, 12 c_int, 13 c_uchar, 14 c_uint, 15 c_void, 16 }; 17 18 19 // 20 // functions 21 // 22 23 #[cfg(target_os="macos")] 24 const LIB_NAME: &'static str = "libOSMesa.dylib"; 25 26 #[cfg(not(target_os="macos"))] 27 const LIB_NAME: &'static str = "libOSMesa.so"; 28 29 shared_library!(OsMesa, LIB_NAME, 30 pub fn OSMesaColorClamp (enable: c_uchar), 31 pub fn OSMesaCreateContext (format: c_uint, sharelist: OSMesaContext) -> OSMesaContext, 32 pub fn OSMesaCreateContextExt (format: c_uint, depthBits: c_int, stencilBits: c_int, accumBits: c_int, sharelist: OSMesaContext) -> OSMesaContext, 33 pub fn OSMesaCreateContextAttribs(attribList: *const c_int, sharelist: OSMesaContext) -> OSMesaContext, 34 pub fn OSMesaDestroyContext (ctx: OSMesaContext), 35 pub fn OSMesaGetColorBuffer (c: OSMesaContext, width: *mut c_int, height: *mut c_int, format: *mut c_int, buffer: *mut *mut c_void) -> c_uchar, 36 pub fn OSMesaGetCurrentContext () -> OSMesaContext, 37 pub fn OSMesaGetDepthBuffer (c: OSMesaContext, width: *mut c_int, height: *mut c_int, bytesPerValue: *mut c_int, buffer: *mut *mut c_void) -> c_uchar, 38 pub fn OSMesaGetIntegerv (pname: c_int, value: *mut c_int), 39 pub fn OSMesaGetProcAddress (funcName: *const c_char) -> OSMESAproc, 40 pub fn OSMesaMakeCurrent (ctx: OSMesaContext, buffer: *mut c_void, _type: c_uint, width: c_int, height: c_int) -> c_uchar, 41 pub fn OSMesaPixelStore (pname: c_int, value: c_int), 42 ); 43 44 45 // 46 // types 47 // 48 49 50 // opaque structs 51 #[repr(C)] pub struct osmesa_context; 52 53 // types 54 pub type OSMesaContext = *mut osmesa_context; 55 pub type OSMESAproc = Option<unsafe extern "C" fn ()>; 56 57 58 // 59 // constants 60 // 61 62 63 // context formats 64 pub const OSMESA_BGRA: c_uint = 0x0001; 65 pub const OSMESA_ARGB: c_uint = 0x0002; 66 pub const OSMESA_BGR: c_uint = 0x0004; 67 pub const OSMESA_RGB_565: c_uint = 0x0005; 68 pub const OSMESA_COLOR_INDEX: c_uint = 0x1900; 69 pub const OSMESA_RGB: c_uint = 0x1907; 70 pub const OSMESA_RGBA: c_uint = 0x1908; 71 72 // OSMesaGetIntegerv 73 pub const OSMESA_WIDTH: c_int = 0x0020; 74 pub const OSMESA_HEIGHT: c_int = 0x0021; 75 pub const OSMESA_FORMAT: c_int = 0x0022; 76 pub const OSMESA_TYPE: c_int = 0x0023; 77 pub const OSMESA_MAX_WIDTH: c_int = 0x0024; 78 pub const OSMESA_MAX_HEIGHT: c_int = 0x0025; 79 80 // OSMesaPixelStore 81 pub const OSMESA_ROW_LENGTH: c_int = 0x0010; 82 pub const OSMESA_Y_UP: c_int = 0x0011; 83 84 // OSMesaCreateContextAttribs 85 pub const OSMESA_DEPTH_BITS: c_int = 0x30; 86 pub const OSMESA_STENCIL_BITS: c_int = 0x31; 87 pub const OSMESA_ACCUM_BITS: c_int = 0x32; 88 pub const OSMESA_PROFILE: c_int = 0x33; 89 pub const OSMESA_CORE_PROFILE: c_int = 0x34; 90 pub const OSMESA_COMPAT_PROFILE: c_int = 0x35; 91 pub const OSMESA_CONTEXT_MAJOR_VERSION: c_int = 0x36; 92 pub const OSMESA_CONTEXT_MINOR_VERSION: c_int = 0x37; 93