text
stringlengths 12
786k
|
---|
let frect_y = field frect " y " float
|
let frect_w = field frect " w " float
|
let frect_h = field frect " h " float
|
let ( ) = seal frect
|
module Frect = struct let create ~ x ~ y ~ w ~ h = let r = make frect in setf r frect_x x ; setf r frect_y y ; setf r frect_w w ; setf r frect_h h ; r let x r = getf r frect_x let y r = getf r frect_y let w r = getf r frect_w let h r = getf r frect_h let set_x r x = setf r frect_x x let set_y r y = setf r frect_y y let set_w r w = setf r frect_w w let set_h r h = setf r frect_h h let opt_addr = function | None -> coerce ( ptr void ) ( ptr rect ) null | Some v -> addr v end
|
let enclose_points = foreign " SDL_EnclosePoints " ( ptr void @-> int @-> ptr rect @-> ptr rect @-> returning bool )
|
let enclose_points_ba ? clip ps = let len = Bigarray . Array1 . dim ps in if len mod 2 <> 0 then invalid_arg ( err_length_mul len 2 ) else let count = len / 2 in let ps = to_voidp ( bigarray_start array1 ps ) in let res = make rect in if enclose_points ps count ( Rect . opt_addr clip ) ( addr res ) then Some res else None
|
let enclose_points ? clip ps = let count = List . length ps in let ps = to_voidp ( CArray . start ( CArray . of_list point ps ) ) in let res = make rect in if enclose_points ps count ( Rect . opt_addr clip ) ( addr res ) then Some res else None
|
let has_intersection = foreign " SDL_HasIntersection " ( ptr rect @-> ptr rect @-> returning bool )
|
let has_intersection a b = has_intersection ( addr a ) ( addr b )
|
let intersect_rect = foreign " SDL_IntersectRect " ( ptr rect @-> ptr rect @-> ptr rect @-> returning bool )
|
let intersect_rect a b = let res = make rect in if intersect_rect ( addr a ) ( addr b ) ( addr res ) then Some res else None
|
let intersect_rect_and_line = foreign " SDL_IntersectRectAndLine " ( ptr rect @-> ptr int @-> ptr int @-> ptr int @-> ptr int @-> returning bool )
|
let intersect_rect_and_line r x1 y1 x2 y2 = let alloc v = allocate int v in let x1 , y1 = alloc x1 , alloc y1 in let x2 , y2 = alloc x2 , alloc y2 in if intersect_rect_and_line ( addr r ) x1 y1 x2 y2 then Some ( ( !@ x1 , !@ y1 ) , ( !@ x2 , !@ y2 ) ) else None
|
let point_in_rect p r = let px = Point . x p in let py = Point . y p in let rx = Rect . x r in let ry = Rect . y r in px >= rx && px < rx + Rect . w r && py >= ry && py < ry + Rect . h r
|
let rect_empty r = Rect . w r <= 0 || Rect . h r <= 0
|
let rect_equals a b = ( Rect . x a = Rect . x b ) && ( Rect . y a = Rect . y b ) && ( Rect . w a = Rect . w b ) && ( Rect . h a = Rect . h b )
|
let union_rect = foreign " SDL_UnionRect " ( ptr rect @-> ptr rect @-> ptr rect @-> returning void )
|
let union_rect a b = let res = make rect in union_rect ( addr a ) ( addr b ) ( addr res ) ; res
|
type palette_struct = _palette structure
|
let palette_struct : palette_struct typ = structure " SDL_Palette "
|
let palette_ncolors = field palette_struct " ncolors " int
|
let palette_colors = field palette_struct " colors " ( ptr color )
|
let _ = field palette_struct " version " uint32_t
|
let _ = field palette_struct " refcount " int
|
let ( ) = seal palette_struct
|
type palette = palette_struct ptr
|
let palette : palette typ = ptr palette_struct
|
let palette_opt : palette option typ = ptr_opt palette_struct
|
let unsafe_palette_of_ptr addr : palette = from_voidp palette_struct ( ptr_of_raw_address addr )
|
let unsafe_ptr_of_palette palette = raw_address_of_ptr ( to_voidp palette )
|
let alloc_palette = foreign " SDL_AllocPalette " ( int @-> returning ( some_to_ok palette_opt ) )
|
let free_palette = foreign " SDL_FreePalette " ( palette @-> returning void )
|
let get_palette_ncolors p = getf ( !@ p ) palette_ncolors
|
let get_palette_colors p = let ps = !@ p in CArray . to_list ( CArray . from_ptr ( getf ps palette_colors ) ( getf ps palette_ncolors ) )
|
let get_palette_colors_ba p = let ps = !@ p in let n = getf ps palette_ncolors in let ba = Bigarray . ( Array1 . create int8_unsigned c_layout ( n * 4 ) ) in let ba_ptr = CArray . from_ptr ( coerce ( ptr int ) ( ptr color ) ( bigarray_start array1 ba ) ) n in let ca = CArray . from_ptr ( getf ps palette_colors ) n in for i = 0 to n - 1 do CArray . set ba_ptr i ( CArray . get ca i ) done ; ba
|
let set_palette_colors = foreign " SDL_SetPaletteColors " ( palette @-> ptr void @-> int @-> int @-> returning zero_to_ok )
|
let set_palette_colors_ba p cs ~ fst = let len = Bigarray . Array1 . dim cs in if len mod 4 <> 0 then invalid_arg ( err_length_mul len 4 ) else let count = len / 4 in let cs = to_voidp ( bigarray_start array1 cs ) in set_palette_colors p cs fst count
|
let set_palette_colors p cs ~ fst = let count = List . length cs in let a = CArray . of_list color cs in set_palette_colors p ( to_voidp ( CArray . start a ) ) fst count
|
type gamma_ramp = ( int , Bigarray . int16_unsigned_elt ) bigarray
|
let calculate_gamma_ramp = foreign " SDL_CalculateGammaRamp " ( float @-> ptr void @-> returning void )
|
let calculate_gamma_ramp g = let ba = Bigarray . ( Array1 . create int16_unsigned c_layout 256 ) in calculate_gamma_ramp g ( to_voidp ( bigarray_start array1 ba ) ) ; ba
|
module Blend = struct type mode = int let mode_none = sdl_blendmode_none let mode_blend = sdl_blendmode_blend let mode_add = sdl_blendmode_add let mode_mod = sdl_blendmode_mod type operation = int let add = sdl_blendoperation_add let subtract = sdl_blendoperation_subtract let rev_subtract = sdl_blendoperation_rev_subtract let minimum = sdl_blendoperation_minimum let maximum = sdl_blendoperation_maximum type factor = int let zero = sdl_blendfactor_zero let one = sdl_blendfactor_one let src_color = sdl_blendfactor_src_color let one_minus_src_color = sdl_blendfactor_one_minus_src_color let src_alpha = sdl_blendfactor_src_alpha let one_minus_src_alpha = sdl_blendfactor_one_minus_src_alpha let dst_color = sdl_blendfactor_dst_color let one_minus_dst_color = sdl_blendfactor_one_minus_dst_color let dst_alpha = sdl_blendfactor_dst_alpha let one_minus_dst_alpha = sdl_blendfactor_one_minus_dst_alpha end
|
let compose_custom_blend_mode = foreign " SDL_ComposeCustomBlendMode " ( int @-> int @-> int @-> int @-> int @-> int @-> returning int )
|
module Pixel = struct type format_enum = Unsigned . UInt32 . t let i = Unsigned . UInt32 . of_int32 let to_uint32 = Unsigned . UInt32 . to_int32 let eq f f ' = Unsigned . UInt32 . ( compare f f ' = 0 ) let format_unknown = i sdl_pixelformat_unknown let format_index1lsb = i sdl_pixelformat_index1lsb let format_index1msb = i sdl_pixelformat_index1msb let format_index4lsb = i sdl_pixelformat_index4lsb let format_index4msb = i sdl_pixelformat_index4msb let format_index8 = i sdl_pixelformat_index8 let format_rgb332 = i sdl_pixelformat_rgb332 let format_rgb444 = i sdl_pixelformat_rgb444 let format_rgb555 = i sdl_pixelformat_rgb555 let format_bgr555 = i sdl_pixelformat_bgr555 let format_argb4444 = i sdl_pixelformat_argb4444 let format_rgba4444 = i sdl_pixelformat_rgba4444 let format_abgr4444 = i sdl_pixelformat_abgr4444 let format_bgra4444 = i sdl_pixelformat_bgra4444 let format_argb1555 = i sdl_pixelformat_argb1555 let format_rgba5551 = i sdl_pixelformat_rgba5551 let format_abgr1555 = i sdl_pixelformat_abgr1555 let format_bgra5551 = i sdl_pixelformat_bgra5551 let format_rgb565 = i sdl_pixelformat_rgb565 let format_bgr565 = i sdl_pixelformat_bgr565 let format_rgb24 = i sdl_pixelformat_rgb24 let format_bgr24 = i sdl_pixelformat_bgr24 let format_rgb888 = i sdl_pixelformat_rgb888 let format_rgbx8888 = i sdl_pixelformat_rgbx8888 let format_bgr888 = i sdl_pixelformat_bgr888 let format_bgrx8888 = i sdl_pixelformat_bgrx8888 let format_argb8888 = i sdl_pixelformat_argb8888 let format_rgba8888 = i sdl_pixelformat_rgba8888 let format_abgr8888 = i sdl_pixelformat_abgr8888 let format_bgra8888 = i sdl_pixelformat_bgra8888 let format_argb2101010 = i sdl_pixelformat_argb2101010 let format_yv12 = i sdl_pixelformat_yv12 let format_iyuv = i sdl_pixelformat_iyuv let format_yuy2 = i sdl_pixelformat_yuy2 let format_uyvy = i sdl_pixelformat_uyvy let format_yvyu = i sdl_pixelformat_yvyu end
|
type pixel_format_struct = _pixel_format structure
|
let pixel_format_struct : pixel_format_struct typ = structure " SDL_PixelFormat "
|
let pf_format = field pixel_format_struct " format " uint32_t
|
let pf_palette = field pixel_format_struct " palette " palette
|
let pf_bits_per_pixel = field pixel_format_struct " BitsPerPixel " uint8_t
|
let pf_bytes_per_pixel = field pixel_format_struct " BytesPerPixel " uint8_t
|
let _ = field pixel_format_struct " padding " uint16_t
|
let _ = field pixel_format_struct " Rmask " uint32_t
|
let _ = field pixel_format_struct " Gmask " uint32_t
|
let _ = field pixel_format_struct " Bmask " uint32_t
|
let _ = field pixel_format_struct " Amask " uint32_t
|
let _ = field pixel_format_struct " Rloss " uint8_t
|
let _ = field pixel_format_struct " Gloss " uint8_t
|
let _ = field pixel_format_struct " Bloss " uint8_t
|
let _ = field pixel_format_struct " Aloss " uint8_t
|
let _ = field pixel_format_struct " Rshift " uint8_t
|
let _ = field pixel_format_struct " Gshift " uint8_t
|
let _ = field pixel_format_struct " Bshift " uint8_t
|
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.