text
stringlengths 0
601k
|
---|
let _ = field pixel_format_struct " Ashift " uint8_t |
let _ = field pixel_format_struct " refcount " int |
let _ = field pixel_format_struct " next " ( ptr pixel_format_struct ) |
let ( ) = seal pixel_format_struct |
type pixel_format = pixel_format_struct ptr |
let pixel_format : pixel_format typ = ptr pixel_format_struct |
let pixel_format_opt : pixel_format option typ = ptr_opt pixel_format_struct |
let unsafe_pixel_format_of_ptr addr : pixel_format = from_voidp pixel_format_struct ( ptr_of_raw_address addr ) |
let unsafe_ptr_of_pixel_format pixel_format = raw_address_of_ptr ( to_voidp pixel_format ) |
let alloc_format = foreign " SDL_AllocFormat " ( uint32_t @-> returning ( some_to_ok pixel_format_opt ) ) |
let free_format = foreign " SDL_FreeFormat " ( pixel_format @-> returning void ) |
let get_pixel_format_name = foreign " SDL_GetPixelFormatName " ( uint32_t @-> returning string ) |
let get_pixel_format_format pf = getf ( !@ pf ) pf_format |
let get_pixel_format_bits_pp pf = Unsigned . UInt8 . to_int ( getf ( !@ pf ) pf_bits_per_pixel ) |
let get_pixel_format_bytes_pp pf = Unsigned . UInt8 . to_int ( getf ( !@ pf ) pf_bytes_per_pixel ) |
let get_rgb = foreign " SDL_GetRGB " ( int32_as_uint32_t @-> pixel_format @-> ptr uint8_t @-> ptr uint8_t @-> ptr uint8_t @-> returning void ) |
let get_rgb pf p = let alloc ( ) = allocate uint8_t Unsigned . UInt8 . zero in let to_int = Unsigned . UInt8 . to_int in let r , g , b = alloc ( ) , alloc ( ) , alloc ( ) in get_rgb p pf r g b ; to_int ( !@ r ) , to_int ( !@ g ) , to_int ( !@ b ) |
let get_rgba = foreign " SDL_GetRGBA " ( int32_as_uint32_t @-> pixel_format @-> ptr uint8_t @-> ptr uint8_t @-> ptr uint8_t @-> ptr uint8_t @-> returning void ) |
let get_rgba pf p = let alloc ( ) = allocate uint8_t Unsigned . UInt8 . zero in let to_int = Unsigned . UInt8 . to_int in let r , g , b , a = alloc ( ) , alloc ( ) , alloc ( ) , alloc ( ) in get_rgba p pf r g b a ; to_int ( !@ r ) , to_int ( !@ g ) , to_int ( !@ b ) , to_int ( !@ a ) |
let map_rgb = foreign " SDL_MapRGB " ( pixel_format @-> int_as_uint8_t @-> int_as_uint8_t @-> int_as_uint8_t @-> returning int32_as_uint32_t ) |
let map_rgba = foreign " SDL_MapRGBA " ( pixel_format @-> int_as_uint8_t @-> int_as_uint8_t @-> int_as_uint8_t @-> int_as_uint8_t @-> returning int32_as_uint32_t ) |
let masks_to_pixel_format_enum = foreign " SDL_MasksToPixelFormatEnum " ( int @-> int32_as_uint32_t @-> int32_as_uint32_t @-> int32_as_uint32_t @-> int32_as_uint32_t @-> returning uint32_t ) |
let pixel_format_enum_to_masks = foreign " SDL_PixelFormatEnumToMasks " ( uint32_t @-> ptr int @-> ptr uint32_t @-> ptr uint32_t @-> ptr uint32_t @-> ptr uint32_t @-> returning bool ) |
let pixel_format_enum_to_masks pf = let ui ( ) = allocate uint32_t ( Unsigned . UInt32 . of_int 0 ) in let get iptr = Unsigned . UInt32 . to_int32 ( !@ iptr ) in let bpp = allocate int 0 in let rm , gm , bm , am = ui ( ) , ui ( ) , ui ( ) , ui ( ) in if not ( pixel_format_enum_to_masks pf bpp rm gm bm am ) then error ( ) else Ok ( !@ bpp , get rm , get gm , get bm , get am ) |
let set_pixel_format_palette = foreign " SDL_SetPixelFormatPalette " ( pixel_format @-> palette @-> returning zero_to_ok ) |
type surface_struct = _surface structure |
let surface_struct : surface_struct typ = structure " SDL_Surface " |
let _ = field surface_struct " flags " uint32_t |
let surface_format = field surface_struct " format " pixel_format |
let surface_w = field surface_struct " w " int |
let surface_h = field surface_struct " h " int |
let surface_pitch = field surface_struct " pitch " int |
let surface_pixels = field surface_struct " pixels " ( ptr void ) |
let _ = field surface_struct " userdata " ( ptr void ) |
let _ = field surface_struct " locked " int |
let _ = field surface_struct " lock_data " ( ptr void ) |
let _ = field surface_struct " clip_rect " rect |
let _ = field surface_struct " map " ( ptr void ) |
let _ = field surface_struct " refcount " int |
let ( ) = seal surface_struct |
type surface = surface_struct ptr |
let surface : surface typ = ptr surface_struct |
let surface_opt : surface option typ = ptr_opt surface_struct |
let unsafe_surface_of_ptr addr : surface = from_voidp surface_struct ( ptr_of_raw_address addr ) |
let unsafe_ptr_of_surface surface = raw_address_of_ptr ( to_voidp surface ) |
let blit_scaled = foreign " SDL_UpperBlitScaled " ( surface @-> ptr rect @-> surface @-> ptr rect @-> returning zero_to_ok ) |
let blit_scaled ~ src sr ~ dst dr = blit_scaled src ( Rect . opt_addr sr ) dst ( Rect . opt_addr dr ) |
let blit_surface = foreign " SDL_UpperBlit " ( surface @-> ptr rect @-> surface @-> ptr rect @-> returning zero_to_ok ) |
let blit_surface ~ src sr ~ dst dr = blit_surface src ( Rect . opt_addr sr ) dst ( Rect . opt_addr dr ) |
let convert_pixels = foreign " SDL_ConvertPixels " ( int @-> int @-> uint32_t @-> ptr void @-> int @-> uint32_t @-> ptr void @-> int @-> returning zero_to_ok ) |
let convert_pixels ~ w ~ h ~ src sp spitch ~ dst dp dpitch = let spitch = ba_kind_byte_size ( Bigarray . Array1 . kind sp ) * spitch in let dpitch = ba_kind_byte_size ( Bigarray . Array1 . kind dp ) * dpitch in let sp = to_voidp ( bigarray_start array1 sp ) in let dp = to_voidp ( bigarray_start array1 dp ) in convert_pixels w h src sp spitch dst dp dpitch |
let convert_surface = foreign " SDL_ConvertSurface " ( surface @-> pixel_format @-> uint32_t @-> returning ( some_to_ok surface_opt ) ) |
let convert_surface s pf = convert_surface s pf Unsigned . UInt32 . zero |
let convert_surface_format = foreign " SDL_ConvertSurfaceFormat " ( surface @-> uint32_t @-> uint32_t @-> returning ( some_to_ok surface_opt ) ) |
let convert_surface_format s pf = convert_surface_format s pf Unsigned . UInt32 . zero |
let create_rgb_surface = foreign " SDL_CreateRGBSurface " ( uint32_t @-> int @-> int @-> int @-> int32_as_uint32_t @-> int32_as_uint32_t @-> int32_as_uint32_t @-> int32_as_uint32_t @-> returning ( some_to_ok surface_opt ) ) |
let create_rgb_surface ~ w ~ h ~ depth rmask gmask bmask amask = create_rgb_surface Unsigned . UInt32 . zero w h depth rmask gmask bmask amask |
let create_rgb_surface_from = foreign " SDL_CreateRGBSurfaceFrom " ( ptr void @-> int @-> int @-> int @-> int @-> int32_as_uint32_t @-> int32_as_uint32_t @-> int32_as_uint32_t @-> int32_as_uint32_t @-> returning ( some_to_ok surface_opt ) ) |
let create_rgb_surface_from p ~ w ~ h ~ depth ~ pitch rmask gmask bmask amask = let pitch = ba_kind_byte_size ( Bigarray . Array1 . kind p ) * pitch in let p = to_voidp ( bigarray_start array1 p ) in create_rgb_surface_from p w h depth pitch rmask gmask bmask amask |
let create_rgb_surface_with_format = foreign " SDL_CreateRGBSurfaceWithFormat " ( uint32_t @-> int @-> int @-> int @-> uint32_t @-> returning ( some_to_ok surface_opt ) ) |
let create_rgb_surface_with_format ~ w ~ h ~ depth format = create_rgb_surface_with_format Unsigned . UInt32 . zero w h depth format |
let create_rgb_surface_with_format_from = foreign " SDL_CreateRGBSurfaceWithFormatFrom " ( ptr void @-> int @-> int @-> int @-> int @-> uint32_t @-> returning ( some_to_ok surface_opt ) ) |
let create_rgb_surface_with_format_from p ~ w ~ h ~ depth ~ pitch format = let pitch = ba_kind_byte_size ( Bigarray . Array1 . kind p ) * pitch in let p = to_voidp ( bigarray_start array1 p ) in create_rgb_surface_with_format_from p w h depth pitch format |
let duplicate_surface = foreign " SDL_DuplicateSurface " ( surface @-> returning surface ) |
let fill_rect = foreign " SDL_FillRect " ( surface @-> ptr rect @-> int32_as_uint32_t @-> returning zero_to_ok ) |
let fill_rect s r c = fill_rect s ( Rect . opt_addr r ) c |
let fill_rects = foreign " SDL_FillRects " ( surface @-> ptr void @-> int @-> int32_as_uint32_t @-> returning zero_to_ok ) |
let fill_rects_ba s rs col = let len = Bigarray . Array1 . dim rs in if len mod 4 <> 0 then invalid_arg ( err_length_mul len 4 ) else let count = len / 4 in let rs = to_voidp ( bigarray_start array1 rs ) in fill_rects s rs count col |
let fill_rects s rs col = let count = List . length rs in let a = CArray . of_list rect rs in fill_rects s ( to_voidp ( CArray . start a ) ) count col |
let free_surface = foreign " SDL_FreeSurface " ( surface @-> returning void ) |
let get_clip_rect = foreign " SDL_GetClipRect " ( surface @-> ptr rect @-> returning void ) |
let get_clip_rect s = let r = make rect in ( get_clip_rect s ( addr r ) ; r ) |
let get_color_key = foreign " SDL_GetColorKey " ( surface @-> ptr uint32_t @-> returning zero_to_ok ) |
let get_color_key s = let key = allocate uint32_t Unsigned . UInt32 . zero in match get_color_key s key with | Ok ( ) -> Ok ( Unsigned . UInt32 . to_int32 ( !@ key ) ) | Error _ as e -> e |
let get_surface_alpha_mod = foreign " SDL_GetSurfaceAlphaMod " ( surface @-> ptr uint8_t @-> returning zero_to_ok ) |
let get_surface_alpha_mod s = let alpha = allocate uint8_t Unsigned . UInt8 . zero in match get_surface_alpha_mod s alpha with | Ok ( ) -> Ok ( Unsigned . UInt8 . to_int ( !@ alpha ) ) | Error _ as e -> e |
let get_surface_blend_mode = foreign " SDL_GetSurfaceBlendMode " ( surface @-> ptr int @-> returning zero_to_ok ) |
let get_surface_blend_mode s = let mode = allocate int 0 in match get_surface_blend_mode s mode with Ok ( ) -> Ok ( !@ mode ) | Error _ as e -> e |
let get_surface_color_mod = foreign " SDL_GetSurfaceColorMod " ( surface @-> ptr uint8_t @-> ptr uint8_t @-> ptr uint8_t @-> returning zero_to_ok ) |
let get_surface_color_mod s = let alloc ( ) = allocate uint8_t Unsigned . UInt8 . zero in let get v = Unsigned . UInt8 . to_int ( !@ v ) in let r , g , b = alloc ( ) , alloc ( ) , alloc ( ) in match get_surface_color_mod s r g b with | Ok ( ) -> Ok ( get r , get g , get b ) | Error _ as e -> e |
let get_surface_format_enum s = get_pixel_format_format ( getf ( !@ s ) surface_format ) |
let get_surface_pitch s = getf ( !@ s ) surface_pitch |
let get_surface_pixels s kind = let pitch = get_surface_pitch s in let kind_size = ba_kind_byte_size kind in if pitch mod kind_size <> 0 then invalid_arg ( err_bigarray_pitch pitch kind_size ) else let h = getf ( !@ s ) surface_h in let ba_size = ( pitch * h ) / kind_size in let pixels = getf ( !@ s ) surface_pixels in let pixels = coerce ( ptr void ) ( access_ptr_typ_of_ba_kind kind ) pixels in bigarray_of_ptr array1 ba_size kind pixels |
let get_surface_size s = getf ( !@ s ) surface_w , getf ( !@ s ) surface_h |
let load_bmp_rw = foreign " SDL_LoadBMP_RW " ( rw_ops @-> bool @-> returning ( some_to_ok surface_opt ) ) |
let load_bmp_rw rw ~ close = load_bmp_rw rw close |
let load_bmp file = match rw_from_file file " rb " with | Error _ as e -> e | Ok rw -> load_bmp_rw rw ~ close : true |
let lock_surface = foreign " SDL_LockSurface " ( surface @-> returning zero_to_ok ) |
let lower_blit = foreign " SDL_LowerBlit " ( surface @-> ptr rect @-> surface @-> ptr rect @-> returning zero_to_ok ) |
let lower_blit ~ src sr ~ dst dr = lower_blit src ( addr sr ) dst ( addr dr ) |
let lower_blit_scaled = foreign " SDL_LowerBlitScaled " ( surface @-> ptr rect @-> surface @-> ptr rect @-> returning zero_to_ok ) |
let lower_blit_scaled ~ src sr ~ dst dr = lower_blit_scaled src ( addr sr ) dst ( addr dr ) |
let save_bmp_rw = foreign " SDL_SaveBMP_RW " ( surface @-> rw_ops @-> bool @-> returning zero_to_ok ) |
let save_bmp_rw s rw ~ close = save_bmp_rw s rw close |
let save_bmp s file = match rw_from_file file " wb " with | Error _ as e -> e | Ok rw -> save_bmp_rw s rw ~ close : true |
let set_clip_rect = foreign " SDL_SetClipRect " ( surface @-> ptr rect @-> returning bool ) |
let set_clip_rect s r = set_clip_rect s ( addr r ) |
let set_color_key = foreign " SDL_SetColorKey " ( surface @-> bool @-> int32_as_uint32_t @-> returning zero_to_ok ) |
let set_surface_alpha_mod = foreign " SDL_SetSurfaceAlphaMod " ( surface @-> int_as_uint8_t @-> returning zero_to_ok ) |
let set_surface_blend_mode = foreign " SDL_SetSurfaceBlendMode " ( surface @-> int @-> returning zero_to_ok ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.