text
stringlengths
12
786k
let quit_sub_system = foreign " SDL_QuitSubSystem " ( uint32_t @-> returning void )
let was_init = foreign " SDL_WasInit " ( uint32_t @-> returning uint32_t )
module Hint = struct type t = string let audio_resampling_mode = sdl_hint_audio_resampling_mode let framebuffer_acceleration = sdl_hint_framebuffer_acceleration let idle_timer_disabled = sdl_hint_idle_timer_disabled let orientations = sdl_hint_orientations let mouse_normal_speed_scale = sdl_hint_mouse_normal_speed_scale let mouse_relative_speed_scale = sdl_hint_mouse_relative_speed_scale let render_driver = sdl_hint_render_driver let render_logical_size_mode = sdl_hint_render_logical_size_mode let render_opengl_shaders = sdl_hint_render_opengl_shaders let render_scale_quality = sdl_hint_render_scale_quality let render_vsync = sdl_hint_render_vsync let no_signal_handlers = sdl_hint_no_signal_handlers let thread_stack_size = sdl_hint_thread_stack_size let touch_mouse_events = sdl_hint_touch_mouse_events let mouse_touch_events = sdl_hint_mouse_touch_events let window_frame_usable_while_cursor_hidden = sdl_hint_window_frame_usable_while_cursor_hidden type priority = int let default = sdl_hint_default let normal = sdl_hint_normal let override = sdl_hint_override end
let clear_hints = foreign " SDL_ClearHints " ( void @-> returning void )
let get_hint = foreign " SDL_GetHint " ( string @-> returning string_opt )
let get_hint_boolean = foreign " SDL_GetHintBoolean " ( string @-> bool @-> returning bool )
let set_hint = foreign " SDL_SetHint " ( string @-> string @-> returning bool )
let set_hint_with_priority = foreign " SDL_SetHintWithPriority " ( string @-> string @-> int @-> returning bool )
let clear_error = foreign " SDL_ClearError " ( void @-> returning void )
let set_error = foreign " SDL_SetError " ( string @-> returning int )
let set_error fmt = kpp ( fun s -> ignore ( set_error s ) ) fmt
module Log = struct type category = int let category_application = sdl_log_category_application let category_error = sdl_log_category_error let category_system = sdl_log_category_system let category_audio = sdl_log_category_audio let category_video = sdl_log_category_video let category_render = sdl_log_category_render let category_input = sdl_log_category_input let category_custom = sdl_log_category_custom type priority = int let priority_compare : int -> int -> int = compare let priority_verbose = sdl_log_priority_verbose let priority_debug = sdl_log_priority_debug let priority_info = sdl_log_priority_info let priority_warn = sdl_log_priority_warn let priority_error = sdl_log_priority_error let priority_critical = sdl_log_priority_critical end
let log_fun_t = ( int @-> string @-> string @-> returning void )
let log = foreign " SDL_Log " ( string @-> string @-> returning void )
let log fmt = kpp ( fun s -> ignore ( log " % s " s ) ) fmt
let log_critical = foreign " SDL_LogCritical " log_fun_t
let log_critical c fmt = kpp ( fun s -> ignore ( log_critical c " % s " s ) ) fmt
let log_debug = foreign " SDL_LogDebug " log_fun_t
let log_debug c fmt = kpp ( fun s -> ignore ( log_debug c " % s " s ) ) fmt
let log_error = foreign " SDL_LogError " log_fun_t
let log_error c fmt = kpp ( fun s -> ignore ( log_error c " % s " s ) ) fmt
let log_info = foreign " SDL_LogInfo " log_fun_t
let log_info c fmt = kpp ( fun s -> ignore ( log_info c " % s " s ) ) fmt
let log_verbose = foreign " SDL_LogVerbose " log_fun_t
let log_verbose c fmt = kpp ( fun s -> ignore ( log_verbose c " % s " s ) ) fmt
let log_warn = foreign " SDL_LogWarn " log_fun_t
let log_warn c fmt = kpp ( fun s -> ignore ( log_warn c " % s " s ) ) fmt
let log_get_priority = foreign " SDL_LogGetPriority " ( int @-> returning int )
let log_message = foreign " SDL_LogMessage " ( int @-> int @-> string @-> string @-> returning void )
let log_message c p fmt = kpp ( fun s -> ignore ( log_message c p " % s " s ) ) fmt
let log_reset_priorities = foreign " SDL_LogResetPriorities " ( void @-> returning void )
let log_set_all_priority = foreign " SDL_LogSetAllPriority " ( int @-> returning void )
let log_set_priority = foreign " SDL_LogSetPriority " ( int @-> int @-> returning void )
let version = structure " SDL_version "
let version_major = field version " major " uint8_t
let version_minor = field version " minor " uint8_t
let version_patch = field version " patch " uint8_t
let ( ) = seal version
let get_version = foreign " SDL_GetVersion " ( ptr version @-> returning void )
let get_version ( ) = let get v f = Unsigned . UInt8 . to_int ( getf v f ) in let v = make version in get_version ( addr v ) ; ( get v version_major ) , ( get v version_minor ) , ( get v version_patch )
let get_revision = foreign " SDL_GetRevision " ( void @-> returning string )
let get_revision_number = foreign " SDL_GetRevisionNumber " ( void @-> returning int )
let rw_ops_struct : _rw_ops structure typ = structure " SDL_RWops "
let rw_ops : _rw_ops structure ptr typ = ptr rw_ops_struct
let rw_ops_opt : _rw_ops structure ptr option typ = ptr_opt rw_ops_struct
let rw_ops_size = field rw_ops_struct " size " ( funptr ( rw_ops @-> returning int64_t ) )
let rw_ops_seek = field rw_ops_struct " seek " ( funptr ( rw_ops @-> int64_t @-> int @-> returning int64_t ) )
let rw_ops_read = field rw_ops_struct " read " ( funptr ( rw_ops @-> ptr void @-> size_t @-> size_t @-> returning size_t ) )
let rw_ops_write = field rw_ops_struct " write " ( funptr ( rw_ops @-> ptr void @-> size_t @-> size_t @-> returning size_t ) )
let rw_ops_close = field rw_ops_struct " close " ( funptr ( rw_ops @-> returning int ) )
let _ = field rw_ops_struct " type " uint32_t
let ( ) = seal rw_ops_struct
type rw_ops = _rw_ops structure ptr
let load_file_rw = foreign " SDL_LoadFile_RW " ( rw_ops @-> ptr int @-> bool @-> returning ( some_to_ok string_opt ) )
let load_file_rw rw_ops close = load_file_rw rw_ops ( coerce ( ptr void ) ( ptr int ) null ) close
let rw_from_file = foreign " SDL_RWFromFile " ( string @-> string @-> returning ( some_to_ok rw_ops_opt ) )
let load_file filename = match rw_from_file filename " rb " with | Error _ as e -> e | Ok rw -> load_file_rw rw true
let rw_close ops = let close = getf ( !@ ops ) rw_ops_close in if close ops = 0 then Ok ( ) else ( error ( ) )
let unsafe_rw_ops_of_ptr addr : rw_ops = from_voidp rw_ops_struct ( ptr_of_raw_address addr )
let unsafe_ptr_of_rw_ops rw_ops = raw_address_of_ptr ( to_voidp rw_ops )
let get_base_path = foreign " SDL_GetBasePath " ( void @-> returning ( ptr char ) )
let get_base_path ( ) = let p = get_base_path ( ) in let path = coerce ( ptr char ) ( some_to_ok string_opt ) p in sdl_free ( coerce ( ptr char ) ( ptr void ) p ) ; path
let get_pref_path = foreign " SDL_GetPrefPath " ( string @-> string @-> returning ( ptr char ) )
let get_pref_path ~ org ~ app = let p = get_pref_path org app in let path = coerce ( ptr char ) ( some_to_ok string_opt ) p in sdl_free ( coerce ( ptr char ) ( ptr void ) p ) ; path
type window = unit ptr
let window : window typ = ptr void
let window_opt : window option typ = ptr_opt void
let unsafe_window_of_ptr addr : window = ptr_of_raw_address addr
let unsafe_ptr_of_window window = raw_address_of_ptr ( to_voidp window )
type color = _color structure
let color : color typ = structure " SDL_Color "
let color_r = field color " r " uint8_t
let color_g = field color " g " uint8_t
let color_b = field color " b " uint8_t
let color_a = field color " a " uint8_t
let ( ) = seal color
module Color = struct let create ~ r ~ g ~ b ~ a = let c = make color in setf c color_r ( Unsigned . UInt8 . of_int r ) ; setf c color_g ( Unsigned . UInt8 . of_int g ) ; setf c color_b ( Unsigned . UInt8 . of_int b ) ; setf c color_a ( Unsigned . UInt8 . of_int a ) ; c let r c = Unsigned . UInt8 . to_int ( getf c color_r ) let g c = Unsigned . UInt8 . to_int ( getf c color_g ) let b c = Unsigned . UInt8 . to_int ( getf c color_b ) let a c = Unsigned . UInt8 . to_int ( getf c color_a ) let set_r c r = setf c color_r ( Unsigned . UInt8 . of_int r ) let set_g c g = setf c color_g ( Unsigned . UInt8 . of_int g ) let set_b c b = setf c color_b ( Unsigned . UInt8 . of_int b ) let set_a c a = setf c color_a ( Unsigned . UInt8 . of_int a ) end
type point = _point structure
let point : point typ = structure " SDL_Point "
let point_x = field point " x " int
let point_y = field point " y " int
let ( ) = seal point
module Point = struct let create ~ x ~ y = let p = make point in setf p point_x x ; setf p point_y y ; p let x p = getf p point_x let y p = getf p point_y let set_x p x = setf p point_x x let set_y p y = setf p point_y y let opt_addr = function | None -> coerce ( ptr void ) ( ptr point ) null | Some v -> addr v end
type fpoint = _fpoint structure
let fpoint : fpoint typ = structure " SDL_FPoint "
let fpoint_x = field fpoint " x " float
let fpoint_y = field fpoint " y " float
let ( ) = seal fpoint
module Fpoint = struct let create ~ x ~ y = let p = make fpoint in setf p fpoint_x x ; setf p fpoint_y y ; p let x p = getf p fpoint_x let y p = getf p fpoint_y let set_x p x = setf p fpoint_x x let set_y p y = setf p fpoint_y y let opt_addr = function | None -> coerce ( ptr void ) ( ptr fpoint ) null | Some v -> addr v end
type rect = _rect structure
let rect : rect typ = structure " SDL_Rect "
let rect_x = field rect " x " int
let rect_y = field rect " y " int
let rect_w = field rect " w " int
let rect_h = field rect " h " int
let ( ) = seal rect
module Rect = struct let create ~ x ~ y ~ w ~ h = let r = make rect in setf r rect_x x ; setf r rect_y y ; setf r rect_w w ; setf r rect_h h ; r let x r = getf r rect_x let y r = getf r rect_y let w r = getf r rect_w let h r = getf r rect_h let set_x r x = setf r rect_x x let set_y r y = setf r rect_y y let set_w r w = setf r rect_w w let set_h r h = setf r rect_h h let opt_addr = function | None -> coerce ( ptr void ) ( ptr rect ) null | Some v -> addr v end
type frect = _frect structure
let frect : frect typ = structure " SDL_FRect "
let frect_x = field frect " x " float