package tsdl

  1. Overview
  2. Docs

SDL bindings.

Integer types, bigarrays and results

type uint8 = int
type int16 = int
type uint16 = int
type uint32 = int32
type uint64 = int64
type ('a, 'b) bigarray = ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t

The type for bigarrays.

type 'a result = ('a, [ `Msg of string ]) Result.result

The type for function results. In the error case, the string is what Sdl.get_error returned.

Basics

Initialization and shutdown

module Init : sig ... end

Subsystem flags.

val init : Init.t -> unit result
val init_sub_system : Init.t -> unit result
val quit : unit -> unit
val quit_sub_system : Init.t -> unit
val was_init : Init.t option -> Init.t

Hints

module Hint : sig ... end
val clear_hints : unit -> unit
val get_hint : Hint.t -> string option
val set_hint : Hint.t -> string -> bool
val set_hint_with_priority : Hint.t -> string -> Hint.priority -> bool

Errors

val clear_error : unit -> unit
val get_error : unit -> string
val set_error : ('b, Format.formatter, unit) format -> 'b

Log

module Log : sig ... end
val log : ('b, Format.formatter, unit) format -> 'b
val log_critical : Log.category -> ('b, Format.formatter, unit) format -> 'b
val log_debug : Log.category -> ('b, Format.formatter, unit) format -> 'b
val log_error : Log.category -> ('b, Format.formatter, unit) format -> 'b
val log_info : Log.category -> ('b, Format.formatter, unit) format -> 'b
val log_message : Log.category -> Log.priority -> ('b, Format.formatter, unit) format -> 'b
val log_reset_priorities : unit -> unit
val log_set_all_priority : Log.priority -> unit
val log_set_priority : Log.category -> Log.priority -> unit
val log_verbose : Log.category -> ('b, Format.formatter, unit) format -> 'b
val log_warn : Log.category -> ('b, Format.formatter, unit) format -> 'b

Version

val get_version : unit -> int * int * int
val get_revision : unit -> string
val get_revision_number : unit -> int

Files and IO abstraction

IO abstraction

type rw_ops
val rw_from_file : string -> string -> rw_ops result
val rw_close : rw_ops -> unit result

Filesystem Paths

val get_base_path : unit -> string result
val get_pref_path : org:string -> app:string -> string result

Video

type window

SDL_Window

Colors

type color
module Color : sig ... end

Points

type point
module Point : sig ... end

Rectangles

type rect
module Rect : sig ... end
val enclose_points : ?clip:rect -> point list -> rect option

SDL_EnclosePoints. Returns None if all the points were outside the clipping rectangle (if provided).

val enclose_points_ba : ?clip:rect -> (int32, Bigarray.int32_elt) bigarray -> rect option

See enclose_points. Each consecutive pair in the array defines a point.

val has_intersection : rect -> rect -> bool
val intersect_rect : rect -> rect -> rect option
val intersect_rect_and_line : rect -> int -> int -> int -> int -> ((int * int) * (int * int)) option

SDL_IntersectRectAndLine. Returns the clipped segment if it intersects.

val rect_empty : rect -> bool
val rect_equals : rect -> rect -> bool
val union_rect : rect -> rect -> rect

Palettes

type palette
val alloc_palette : int -> palette result
val free_palette : palette -> unit
val get_palette_ncolors : palette -> int

get_palette_ncolors p is the field ncolors of p.

val get_palette_colors : palette -> color list

get_palette_colors p is a copy of the contents of the field colors of s.

val get_palette_colors_ba : palette -> (int, Bigarray.int8_unsigned_elt) bigarray

get_palette_colors_ba p is a copy of the contents of the field colors of p.

val set_palette_colors : palette -> color list -> fst:int -> unit result
val set_palette_colors_ba : palette -> (int, Bigarray.int8_unsigned_elt) bigarray -> fst:int -> unit result

See set_palette_colors. Each consecutive quadruplet defines a color. The data is copied.

Pixels formats

type gamma_ramp = (int, Bigarray.int16_unsigned_elt) bigarray

The type for gamma ramps, 256 uint16 values.

val calculate_gamma_ramp : float -> gamma_ramp
module Blend : sig ... end
module Pixel : sig ... end
type pixel_format
val free_format : pixel_format -> unit
val get_pixel_format_name : Pixel.format_enum -> string
val get_pixel_format_format : pixel_format -> Pixel.format_enum

get_pixel_format_format pf is the field format of pf.

val get_pixel_format_bits_pp : pixel_format -> int

get_pixel_format_bits_pp pf is the field BitsPerPixel of pf.

val get_pixel_format_bytes_pp : pixel_format -> int

get_pixel_format_bytes_pp pf is the field BytesPerPixel of pf.

val map_rgb : pixel_format -> uint8 -> uint8 -> uint8 -> uint32
val map_rgba : pixel_format -> uint8 -> uint8 -> uint8 -> uint8 -> uint32
val masks_to_pixel_format_enum : int -> uint32 -> uint32 -> uint32 -> uint32 -> Pixel.format_enum
val pixel_format_enum_to_masks : Pixel.format_enum -> (int * uint32 * uint32 * uint32 * uint32) result
val set_pixel_format_palette : pixel_format -> palette -> unit result

SDL_SetPixelFormatPalette.

Note If you allocated the palette with alloc_palette you can free_palette after.

Surface

type surface
val blit_scaled : src:surface -> rect option -> dst:surface -> rect option -> unit result
val blit_surface : src:surface -> rect option -> dst:surface -> rect option -> unit result
val convert_pixels : w:int -> h:int -> src:Pixel.format_enum -> ('a, 'b) bigarray -> int -> dst:Pixel.format_enum -> ('c, 'd) bigarray -> int -> unit result

SDL_ConvertPixels

Note Pitches are given in bigarray elements not in bytes.

Warning. Unsafe, make sure your parameters don't result in invalid access to memory.

val create_rgb_surface : w:int -> h:int -> depth:int -> uint32 -> uint32 -> uint32 -> uint32 -> surface result
val create_rgb_surface_from : ('a, 'b) bigarray -> w:int -> h:int -> depth:int -> pitch:int -> uint32 -> uint32 -> uint32 -> uint32 -> surface result

SDL_CreateRGBSurfaceFrom

Note The pitch is given in bigarray elements not in bytes.

Warning Unsafe, make sure your parameters don't result in invalid access to memory. The bigarray data is not copied, it must remain valid until free_surface is called on the surface.

val fill_rect : surface -> rect option -> uint32 -> unit result
val fill_rects : surface -> rect list -> uint32 -> unit result
val fill_rects_ba : surface -> (int32, Bigarray.int32_elt) bigarray -> uint32 -> unit result

See fill_rects. Each consecutive quadruplet defines a rectangle.

val free_surface : surface -> unit
val get_clip_rect : surface -> rect
val get_color_key : surface -> uint32 result
val get_surface_alpha_mod : surface -> uint8 result
val get_surface_blend_mode : surface -> Blend.mode result
val get_surface_color_mod : surface -> (int * int * int) result
val get_surface_format_enum : surface -> Pixel.format_enum

get_surface_format_neum s is the pixel format enum of the field format of s.

val get_surface_pitch : surface -> int

get_surface_pitch s is the field pitch of s.

val get_surface_pixels : surface -> ('a, 'b) Bigarray.kind -> ('a, 'b) bigarray

get_surface_pixels s kind is the field pixels of s viewed as a kind bigarray. Note that you must lock the surface before accessing this.

Warning. The bigarray memory becomes invalid once the surface is unlocked or freed.

val get_surface_size : surface -> int * int

get_surface_size s is the fields w and h of s.

val load_bmp : string -> surface result
val load_bmp_rw : rw_ops -> close:bool -> surface result
val lock_surface : surface -> unit result
val lower_blit : src:surface -> rect -> dst:surface -> rect -> unit result
val lower_blit_scaled : src:surface -> rect -> dst:surface -> rect -> unit result
val save_bmp : surface -> string -> unit result
val save_bmp_rw : surface -> rw_ops -> close:bool -> unit result
val set_clip_rect : surface -> rect -> bool
val set_color_key : surface -> bool -> uint32 -> unit result
val set_surface_alpha_mod : surface -> uint8 -> unit result
val set_surface_blend_mode : surface -> Blend.mode -> unit result
val set_surface_color_mod : surface -> uint8 -> uint8 -> uint8 -> unit result
val set_surface_palette : surface -> palette -> unit result

SDL_SetSurfacePalette

Note If you allocated the palette with alloc_palette you can free_palette after.

val set_surface_rle : surface -> bool -> unit result
val unlock_surface : surface -> unit

Renderers

module Flip : sig ... end
type texture

SDL_Texture

type renderer

SDL_Renderer

module Renderer : sig ... end
type renderer_info = {
  1. ri_name : string;
  2. ri_flags : Renderer.flags;
  3. ri_texture_formats : Pixel.format_enum list;
  4. ri_max_texture_width : int;
  5. ri_max_texture_height : int;
}
val create_renderer : ?index:int -> ?flags:Renderer.flags -> window -> renderer result
val create_software_renderer : surface -> renderer result
val destroy_renderer : renderer -> unit
val get_num_render_drivers : unit -> int result
val get_render_draw_blend_mode : renderer -> Blend.mode result
val get_render_draw_color : renderer -> (uint8 * uint8 * uint8 * uint8) result
val get_render_driver_info : int -> renderer_info result
val get_render_target : renderer -> texture option
val get_renderer : window -> renderer result
val get_renderer_output_size : renderer -> (int * int) result
val render_clear : renderer -> unit result
val render_copy : ?src:rect -> ?dst:rect -> renderer -> texture -> unit result
val render_copy_ex : ?src:rect -> ?dst:rect -> renderer -> texture -> float -> point option -> flip -> unit result
val render_draw_line : renderer -> int -> int -> int -> int -> unit result
val render_draw_lines : renderer -> point list -> unit result
val render_draw_lines_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_lines. Each consecutive pair in the array defines a point.

val render_draw_point : renderer -> int -> int -> unit result
val render_draw_points : renderer -> point list -> unit result
val render_draw_points_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_points. Each consecutive pair in the array defines a point.

val render_draw_rect : renderer -> rect option -> unit result
val render_draw_rects : renderer -> rect list -> unit result
val render_draw_rects_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_rects. Each consecutive quadruple in the array defines a rectangle.

val render_fill_rect : renderer -> rect option -> unit result
val render_fill_rects : renderer -> rect list -> unit result
val render_fill_rects_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_rects. Each consecutive quadruple in the array defines a rectangle.

val render_get_clip_rect : renderer -> rect
val render_get_logical_size : renderer -> int * int
val render_get_scale : renderer -> float * float
val render_get_viewport : renderer -> rect
val render_present : renderer -> unit
val render_read_pixels : renderer -> rect option -> Pixel.format_enum option -> ('a, 'b) bigarray -> int -> unit result
val render_set_clip_rect : renderer -> rect option -> unit result
val render_set_logical_size : renderer -> int -> int -> unit result
val render_set_scale : renderer -> float -> float -> unit result
val render_set_viewport : renderer -> rect option -> unit result
val render_target_supported : renderer -> bool
val set_render_draw_blend_mode : renderer -> Blend.mode -> unit result
val set_render_draw_color : renderer -> uint8 -> uint8 -> uint8 -> uint8 -> unit result
val set_render_target : renderer -> texture option -> unit result

Textures

module Texture : sig ... end
val create_texture : renderer -> Pixel.format_enum -> Texture.access -> w:int -> h:int -> texture result
val create_texture_from_surface : renderer -> surface -> texture result
val destroy_texture : texture -> unit
val get_texture_alpha_mod : texture -> uint8 result
val get_texture_blend_mode : texture -> Blend.mode result
val get_texture_color_mod : texture -> (uint8 * uint8 * uint8) result
val lock_texture : texture -> rect option -> ('a, 'b) Bigarray.kind -> (('a, 'b) bigarray * int) result

SDL_LockTexture

Note. The returned pitch is in bigarray element, not in bytes.

val query_texture : texture -> (Pixel.format_enum * Texture.access * (int * int)) result
val set_texture_alpha_mod : texture -> uint8 -> unit result
val set_texture_blend_mode : texture -> Blend.mode -> unit result
val set_texture_color_mod : texture -> uint8 -> uint8 -> uint8 -> unit result
val unlock_texture : texture -> unit
val update_texture : texture -> rect option -> ('a, 'b) bigarray -> int -> unit result

SDL_UpdateTexture

Note The pitch is given in bigarray elements not in bytes.

val update_yuv_texture : texture -> rect option -> y:(int, Bigarray.int8_unsigned_elt) bigarray -> int -> u:(int, Bigarray.int8_unsigned_elt) bigarray -> int -> v:(int, Bigarray.int8_unsigned_elt) bigarray -> int -> unit result

Video drivers

val get_current_video_driver : unit -> string option
val get_num_video_drivers : unit -> int result
val get_video_driver : int -> string result
val video_init : string option -> unit result
val video_quit : unit -> unit

Displays

type driverdata

Note. Nothing can be done with that.

type display_mode = {
  1. dm_format : Pixel.format_enum;
  2. dm_w : int;
  3. dm_h : int;
  4. dm_refresh_rate : int option;
  5. dm_driverdata : driverdata option;
}
val get_closest_display_mode : int -> display_mode -> display_mode option
val get_current_display_mode : int -> display_mode result
val get_desktop_display_mode : int -> display_mode result
val get_display_bounds : int -> rect result
val get_display_mode : int -> int -> display_mode result
val get_display_name : int -> string result
val get_num_display_modes : int -> int result
val get_num_video_displays : unit -> int result

Windows

module Window : sig ... end
val create_window : string -> ?x:int -> ?y:int -> w:int -> h:int -> Window.flags -> window result
val create_window_and_renderer : w:int -> h:int -> Window.flags -> (window * renderer) result
val destroy_window : window -> unit
val get_window_brightness : window -> float
val get_window_display_index : window -> int result
val get_window_display_mode : window -> display_mode result
val get_window_flags : window -> Window.flags
val get_window_from_id : int -> window result
val get_window_grab : window -> bool
val get_window_id : window -> int
val get_window_maximum_size : window -> int * int
val get_window_minimum_size : window -> int * int
val get_window_pixel_format : window -> Pixel.format_enum
val get_window_position : window -> int * int
val get_window_size : window -> int * int
val get_window_surface : window -> surface result

SDL_GetWindowSurface.

Note. According to SDL's documentation the surface is freed when the window is destroyed.

val get_window_title : window -> string
val hide_window : window -> unit
val maximize_window : window -> unit
val minimize_window : window -> unit
val raise_window : window -> unit
val restore_window : window -> unit
val set_window_bordered : window -> bool -> unit
val set_window_brightness : window -> float -> unit result
val set_window_display_mode : window -> display_mode -> unit result
val set_window_fullscreen : window -> Window.flags -> unit result
val set_window_gamma_ramp : window -> gamma_ramp -> gamma_ramp -> gamma_ramp -> unit result
val set_window_grab : window -> bool -> unit
val set_window_icon : window -> surface -> unit
val set_window_maximum_size : window -> w:int -> h:int -> unit
val set_window_minimum_size : window -> w:int -> h:int -> unit
val set_window_position : window -> x:int -> y:int -> unit
val set_window_size : window -> w:int -> h:int -> unit
val set_window_title : window -> string -> unit
val show_window : window -> unit
val update_window_surface : window -> unit result
val update_window_surface_rects : window -> rect list -> unit result
val update_window_surface_rects_ba : window -> (int32, Bigarray.int32_elt) bigarray -> unit result

See update_window_surface_rects. Each consecutive quadruplet defines a rectangle.

OpenGL contexts

type gl_context

SDL_GLContext

module Gl : sig ... end
val gl_create_context : window -> gl_context result
val gl_bind_texture : texture -> (float * float) result
val gl_delete_context : gl_context -> unit
val gl_extension_supported : string -> bool
val gl_get_attribute : Gl.attr -> int result
val gl_get_current_context : unit -> gl_context result
val gl_get_drawable_size : window -> int * int
val gl_get_swap_interval : unit -> int result
val gl_make_current : window -> gl_context -> unit result
val gl_set_attribute : Gl.attr -> int -> unit result
val gl_set_swap_interval : int -> unit result
val gl_swap_window : window -> unit
val gl_reset_attributes : unit -> unit
val gl_unbind_texture : texture -> unit result

SDL_GL_UnbindTexture Warning Segfaults on SDL 2.0.1 see this report.

Screen saver

val disable_screen_saver : unit -> unit
val enable_screen_saver : unit -> unit
val is_screen_saver_enabled : unit -> bool

Message boxes

module Message_box : sig ... end
val show_message_box : Message_box.data -> int result
val show_simple_message_box : Message_box.flags -> title:string -> string -> window option -> unit result

Clipboard

val get_clipboard_text : unit -> string result
val has_clipboard_text : unit -> bool
val set_clipboard_text : string -> unit result

Input

type button_state
val pressed : button_state
val released : button_state
type toggle_state
val disable : toggle_state
val enable : toggle_state

Keyboard

type scancode = int
module Scancode : sig ... end

Constants and enumeration for scancode

type keycode = int
module K : sig ... end

Constants for keycode

type keymod = int
module Kmod : sig ... end

Constants for keymod

val get_keyboard_focus : unit -> window option
val get_keyboard_state : unit -> (int, Bigarray.int8_unsigned_elt) bigarray
val get_key_from_name : string -> keycode
val get_key_from_scancode : scancode -> keycode
val get_key_name : keycode -> string
val get_mod_state : unit -> keymod
val get_scancode_from_key : keycode -> scancode
val get_scancode_from_name : string -> scancode
val get_scancode_name : scancode -> string
val has_screen_keyboard_support : unit -> bool
val is_screen_keyboard_shown : window -> bool
val is_text_input_active : unit -> bool
val set_mod_state : keymod -> unit
val set_text_input_rect : rect option -> unit
val start_text_input : unit -> unit
val stop_text_input : unit -> unit

Mouse

type cursor

SDL_Cursor

module System_cursor : sig ... end
module Button : sig ... end
val create_color_cursor : surface -> hot_x:int -> hot_y:int -> cursor result
val create_cursor : (int, Bigarray.int8_unsigned_elt) bigarray -> (int, Bigarray.int8_unsigned_elt) bigarray -> w:int -> h:int -> hot_x:int -> hot_y:int -> cursor result
val free_cursor : cursor -> unit
val get_cursor : unit -> cursor option
val get_default_cursor : unit -> cursor option
val get_mouse_focus : unit -> window option
val get_mouse_state : unit -> uint32 * (int * int)
val get_relative_mouse_mode : unit -> bool
val get_relative_mouse_state : unit -> uint32 * (int * int)
val get_cursor_shown : unit -> bool result

SDL_ShowCursor with SDL_QUERY.

val set_cursor : cursor option -> unit
val set_relative_mouse_mode : bool -> unit result
val show_cursor : bool -> bool result
val warp_mouse_in_window : window option -> x:int -> y:int -> unit

Touch and gestures

type touch_id = int64

SDL_TouchID

val touch_mouse_id : touch_id

SDL_TOUCH_MOUSEID

type gesture_id = int64

SDL_GestureID

type finger_id = int64

SDL_FingerID

type finger

SDL_Finger

module Finger : sig ... end
val get_num_touch_devices : unit -> int
val get_num_touch_fingers : touch_id -> int
val get_touch_device : int -> touch_id result
val get_touch_finger : touch_id -> int -> finger option
val load_dollar_templates : touch_id -> rw_ops -> unit result
val record_gesture : touch_id -> unit result
val save_dollar_template : gesture_id -> rw_ops -> unit result
val save_all_dollar_templates : rw_ops -> unit result

Joystick

type joystick_guid

SDL_JoystickGUID.

type joystick_id = int32

SDL_JoystickID

type joystick

SDL_Joystick

module Hat : sig ... end
val joystick_close : joystick -> unit
val joystick_get_event_state : unit -> toggle_state result

SDL_JoystickEventState with SDL_QUERY.

val joystick_get_attached : joystick -> bool
val joystick_get_axis : joystick -> int -> int16
val joystick_get_ball : joystick -> int -> (int * int) result
val joystick_get_button : joystick -> int -> uint8
val joystick_get_device_guid : int -> joystick_guid
val joystick_get_guid : joystick -> joystick_guid
val joystick_get_guid_from_string : string -> joystick_guid
val joystick_get_guid_string : joystick_guid -> string
val joystick_get_hat : joystick -> int -> Hat.t
val joystick_instance_id : joystick -> joystick_id result
val joystick_name : joystick -> string result
val joystick_name_for_index : int -> string result
val joystick_num_axes : joystick -> int result
val joystick_num_balls : joystick -> int result
val joystick_num_buttons : joystick -> int result
val joystick_num_hats : joystick -> int result
val joystick_open : int -> joystick result
val joystick_update : unit -> unit
val num_joysticks : unit -> int result

Game controller

type game_controller

SDL_GameController

module Controller : sig ... end
val game_controller_add_mapping : string -> bool result
val game_controller_add_mapping_from_file : string -> int result
val game_controller_add_mapping_from_rw : rw_ops -> bool -> int result
val game_controller_close : game_controller -> unit
val game_controller_get_event_state : unit -> toggle_state result
val game_controller_get_attached : game_controller -> bool
val game_controller_get_axis_from_string : string -> Controller.axis
val game_controller_get_button_from_string : string -> Controller.button
val game_controller_get_joystick : game_controller -> joystick result
val game_controller_get_string_for_axis : Controller.axis -> string option
val game_controller_get_string_for_button : Controller.button -> string option
val game_controller_mapping : game_controller -> string result
val game_controller_mapping_for_guid : joystick_guid -> string result
val game_controller_name : game_controller -> string result
val game_controller_name_for_index : int -> string result
val game_controller_open : int -> game_controller result
val game_controller_update : unit -> unit
val is_game_controller : int -> bool

Events

type event_type = int

SDL_EventType. See Event for constants.

type event
module Event : sig ... end

event accessors and event_type constants and enumeration.

val get_event_state : event_type -> toggle_state

SDL_EventState with SDL_QUERY.

val set_event_state : event_type -> toggle_state -> unit
val flush_event : event_type -> unit
val flush_events : event_type -> event_type -> unit
val has_event : event_type -> bool
val has_events : event_type -> event_type -> bool
val poll_event : event option -> bool
val pump_events : unit -> unit
val push_event : event -> bool result
val register_event : unit -> event_type option

SDL_RegisterEvents called with 1.

val wait_event : event option -> unit result
val wait_event_timeout : event option -> int -> bool

Force Feedback

type haptic
type haptic_effect
type haptic_effect_id
module Haptic : sig ... end
val haptic_close : haptic -> unit
val haptic_destroy_effect : haptic -> haptic_effect_id -> unit
val haptic_effect_supported : haptic -> haptic_effect -> bool result
val haptic_get_effect_status : haptic -> haptic_effect_id -> bool result
val haptic_index : haptic -> int result
val haptic_name : int -> string result
val haptic_num_axes : haptic -> int result
val haptic_num_effects : haptic -> int result
val haptic_num_effects_playing : haptic -> int result
val haptic_open : int -> haptic result
val haptic_open_from_joystick : joystick -> haptic result
val haptic_open_from_mouse : unit -> haptic result
val haptic_opened : int -> bool
val haptic_pause : haptic -> unit result
val haptic_query : haptic -> int
val haptic_rumble_init : haptic -> unit result
val haptic_rumble_play : haptic -> float -> uint32 -> unit result
val haptic_rumble_stop : haptic -> unit result
val haptic_rumble_supported : haptic -> bool result
val haptic_run_effect : haptic -> haptic_effect_id -> uint32 -> unit result
val haptic_set_autocenter : haptic -> int -> unit result
val haptic_set_gain : haptic -> int -> unit result
val haptic_stop_all : haptic -> unit result
val haptic_stop_effect : haptic -> haptic_effect_id -> unit result
val haptic_unpause : haptic -> unit result
val haptic_update_effect : haptic -> haptic_effect_id -> haptic_effect -> unit result
val joystick_is_haptic : joystick -> bool result
val mouse_is_haptic : unit -> bool result
val num_haptics : unit -> int result

Audio

module Audio : sig ... end

Audio drivers

val audio_init : string option -> unit result
val audio_quit : unit -> unit
val get_audio_driver : int -> string result
val get_current_audio_driver : unit -> string option
val get_num_audio_drivers : unit -> int result

Audio devices

type audio_device_id = uint32
type audio_callback

The type for audio callbacks.

val audio_callback : ('a, 'b) Bigarray.kind -> (('a, 'b) bigarray -> unit) -> audio_callback

audio_callback k f is an audio callback. A reference needs to be kept on the callback value until it is no longer needed.

type audio_spec = {
  1. as_freq : int;
  2. as_format : Audio.format;
  3. as_channels : uint8;
  4. as_silence : uint8;
  5. as_samples : uint8;
  6. as_size : uint32;
  7. as_callback : audio_callback option;
}
val close_audio_device : audio_device_id -> unit
val free_wav : ('a, 'b) bigarray -> unit
val get_audio_device_name : int -> bool -> string result
val get_audio_device_status : audio_device_id -> Audio.status
val get_num_audio_devices : bool -> int result
val load_wav_rw : rw_ops -> audio_spec -> ('a, 'b) Bigarray.kind -> (audio_spec * ('a, 'b) bigarray) result
val lock_audio_device : audio_device_id -> unit
val open_audio_device : string option -> bool -> audio_spec -> Audio.allow -> (audio_device_id * audio_spec) result
val pause_audio_device : audio_device_id -> bool -> unit
val unlock_audio_device : audio_device_id -> unit

Timer

val delay : uint32 -> unit
val get_ticks : unit -> uint32
val get_performance_counter : unit -> uint64
val get_performance_frequency : unit -> uint64

Platform and CPU information

val get_platform : unit -> string
val get_cpu_cache_line_size : unit -> int result
val get_cpu_count : unit -> int
val get_system_ram : unit -> int
val has_3d_now : unit -> bool
val has_altivec : unit -> bool
val has_avx : unit -> bool

SDL_HasAVX (SDL 2.0.2)

val has_mmx : unit -> bool
val has_rdtsc : unit -> bool
val has_sse : unit -> bool
val has_sse2 : unit -> bool
val has_sse3 : unit -> bool
val has_sse41 : unit -> bool
val has_sse42 : unit -> bool

Power

type power_state = [
  1. | `Unknown
  2. | `On_battery
  3. | `No_battery
  4. | `Charging
  5. | `Charged
]
type power_info = {
  1. pi_state : power_state;
  2. pi_secs : int option;
  3. pi_pct : int option;
}
val get_power_info : unit -> power_info

Binding Coverage

Everything except the following functions/categories are available.

Unbound categories

Unbound functions

OCaml

Innovation. Community. Security.