Library
Module
Module type
Parameter
Class
Class type
SDL bindings.
type ('a, 'b) bigarray = ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t
The type for bigarrays.
type nonrec 'a result = ('a, [ `Msg of string ]) result
The type for function results. In the error case, the string is what Sdl.get_error
returned.
module Init : sig ... end
Subsystem flags.
val quit_sub_system : Init.t -> unit
module Hint : sig ... end
val get_hint : Hint.t -> string option
val get_hint_boolean : Hint.t -> bool -> bool
SDL_GetHintBoolean ( 2.05.0 )
val set_hint : Hint.t -> string -> bool
val set_hint_with_priority : Hint.t -> string -> Hint.priority -> bool
val set_error : ('b, Format.formatter, unit) format -> 'b
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_get_priority : Log.category -> Log.priority
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_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
val load_file : string -> string result
( 2.06.0 )
val get_base_path : unit -> string result
val get_pref_path : org:string -> app:string -> string result
module Color : sig ... end
module Point : sig ... end
module Rect : sig ... end
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 intersect_rect_and_line :
rect ->
int ->
int ->
int ->
int ->
((int * int) * (int * int)) option
SDL_IntersectRectAndLine. Returns the clipped segment if it intersects.
SDL_PointInRect ( 2.04.0 )
val rect_empty : rect -> bool
val free_palette : palette -> unit
val get_palette_ncolors : palette -> int
get_palette_ncolors p
is the field ncolors
of p
.
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_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.
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
val compose_custom_blend_mode :
Blend.factor ->
Blend.factor ->
Blend.operation ->
Blend.factor ->
Blend.factor ->
Blend.operation ->
Blend.mode
SDL_ComposeCustomBlendMode ( 2.06.0 )
module Pixel : sig ... end
val alloc_format : Pixel.format_enum -> pixel_format result
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 get_rgb : pixel_format -> uint32 -> uint8 * uint8 * uint8
val map_rgb : pixel_format -> uint8 -> uint8 -> uint8 -> uint32
val masks_to_pixel_format_enum :
int ->
uint32 ->
uint32 ->
uint32 ->
uint32 ->
Pixel.format_enum
val set_pixel_format_palette : pixel_format -> palette -> unit result
Note If you allocated the palette with alloc_palette
you can free_palette
after.
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
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 convert_surface : surface -> pixel_format -> surface result
val convert_surface_format : surface -> Pixel.format_enum -> surface result
val create_rgb_surface_from :
('a, 'b) bigarray ->
w:int ->
h:int ->
depth:int ->
pitch:int ->
uint32 ->
uint32 ->
uint32 ->
uint32 ->
surface result
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 create_rgb_surface_with_format :
w:int ->
h:int ->
depth:int ->
Pixel.format_enum ->
surface result
SDL_CreateRGBSurfaceWithFormat ( 2.05.0 )
val create_rgb_surface_with_format_from :
('a, 'b) bigarray ->
w:int ->
h:int ->
depth:int ->
pitch:int ->
Pixel.format_enum ->
surface result
SDL_CreateRGBSurfaceWithFormatFrom ( 2.05.0 )
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_surface_blend_mode : surface -> Blend.mode 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 set_surface_blend_mode : surface -> Blend.mode -> unit result
Note If you allocated the palette with alloc_palette
you can free_palette
after.
val unlock_surface : surface -> unit
module Flip : sig ... end
SDL_Renderer
module Renderer : sig ... end
type renderer_info = {
ri_name : string;
ri_flags : Renderer.flags;
ri_texture_formats : Pixel.format_enum list;
ri_max_texture_width : int;
ri_max_texture_height : int;
}
val create_renderer :
?index:int ->
?flags:Renderer.flags ->
window ->
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_driver_info : int -> renderer_info result
val get_renderer_info : renderer -> renderer_info 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_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_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_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_integer_scale : renderer -> bool
SDL_RenderGetIntegerScale ( 2.05.0 )
val render_get_logical_size : renderer -> int * int
val render_get_scale : renderer -> float * float
val render_is_clip_enabled : renderer -> bool
SDL_RenderIsClipEnabled ( 2.04.0 )
val render_present : renderer -> unit
val render_read_pixels :
renderer ->
rect option ->
Pixel.format_enum option ->
('a, 'b) bigarray ->
int ->
unit result
SDL_RenderSetIntegerScale ( 2.05.0 )
val render_target_supported : renderer -> bool
val set_render_draw_blend_mode : renderer -> Blend.mode -> unit result
module Texture : sig ... end
val create_texture :
renderer ->
Pixel.format_enum ->
Texture.access ->
w:int ->
h:int ->
texture result
val destroy_texture : texture -> unit
val get_texture_blend_mode : texture -> Blend.mode result
val lock_texture :
texture ->
rect option ->
('a, 'b) Bigarray.kind ->
(('a, 'b) bigarray * int) result
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_blend_mode : texture -> Blend.mode -> unit result
val unlock_texture : texture -> unit
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
val get_num_video_drivers : unit -> int result
val get_video_driver : int -> string result
val video_init : string option -> unit result
type display_mode = {
dm_format : Pixel.format_enum;
dm_w : int;
dm_h : int;
dm_refresh_rate : int option;
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_dpi : int -> (float * float * float) result
SDL_GetDisplayDPI ( 2.04.0 )
val get_display_mode : int -> int -> display_mode result
val get_display_name : int -> string result
SDL_GetDisplayUsableBouds ( 2.05.0 )
val get_num_display_modes : int -> int result
val get_num_video_displays : unit -> int result
module Window : sig ... end
val create_window :
string ->
?x:int ->
?y:int ->
w:int ->
h:int ->
Window.flags ->
window result
x
and y
default to Window.pos_undefined
.
val create_window_and_renderer :
w:int ->
h:int ->
Window.flags ->
(window * renderer) result
val destroy_window : window -> unit
SDL_GetWindowBordersSize ( 2.05.0 )
val get_window_brightness : window -> float
val get_window_display_mode : window -> display_mode result
val get_window_flags : window -> Window.flags
val get_window_gamma_ramp :
window ->
(gamma_ramp * gamma_ramp * gamma_ramp) result
val get_window_grab : window -> bool
val get_grabbed_window : unit -> window
SDL_GetGrabbedWindow ( 2.04.0 )
val get_window_id : window -> int
val get_window_maximum_size : window -> int * int
val get_window_minimum_size : window -> int * int
SDL_GetWindowOpacity ( 2.05.0 )
val get_window_pixel_format : window -> Pixel.format_enum
val get_window_position : window -> int * int
val get_window_size : window -> int * int
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_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_maximum_size : window -> w:int -> h:int -> unit
val set_window_minimum_size : window -> w:int -> h:int -> unit
SDL_SetWindowModalFor ( 2.05.0 )
SDL_SetWindowOpacity ( 2.05.0 )
val set_window_position : window -> x:int -> y:int -> unit
val set_window_resizable : window -> bool -> unit
SDL_SetWindowResizable ( 2.05.0 )
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_rects_ba :
window ->
(int32, Bigarray.int32_elt) bigarray ->
unit result
See update_window_surface_rects
. Each consecutive quadruplet defines a rectangle.
SDL_GLContext
module Gl : sig ... end
val gl_create_context : window -> gl_context result
val gl_delete_context : gl_context -> unit
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_swap_interval : int -> unit result
val gl_swap_window : window -> unit
SDL_GL_ResetAttributes (SDL 2.0.2).
SDL_GL_UnbindTexture Warning Segfaults on SDL 2.0.1 see this report.
module Vulkan : sig ... end
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
val get_clipboard_text : unit -> string result
val set_clipboard_text : string -> unit result
val pressed : button_state
val released : button_state
val disable : toggle_state
val enable : toggle_state
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_name : keycode -> string
val get_mod_state : unit -> keymod
val get_scancode_from_name : string -> scancode
val get_scancode_name : scancode -> string
val is_screen_keyboard_shown : window -> bool
val set_mod_state : keymod -> unit
val set_text_input_rect : rect option -> unit
SDL_Cursor
module System_cursor : sig ... end
module Button : sig ... end
val capture_mouse : bool -> unit result
SDL_CaptureMouse ( 2.04.0 )
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 create_system_cursor : System_cursor.t -> cursor result
val free_cursor : cursor -> unit
val get_cursor : unit -> cursor option
val get_default_cursor : unit -> cursor option
val get_global_mouse_state : unit -> uint32 * (int * int)
SDL_GetGlobalMouseState ( 2.04.0 )
val get_mouse_focus : unit -> window option
val get_mouse_state : unit -> uint32 * (int * int)
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
SDL_ShowCursor. See also get_cursor_shown
.
val warp_mouse_global : x:int -> y:int -> unit result
SDL_WarpMouseGlobal ( 2.04.0 )
val warp_mouse_in_window : window option -> x:int -> y:int -> unit
val touch_mouse_id : touch_id
SDL_TOUCH_MOUSEID
module Finger : sig ... end
val get_num_touch_fingers : touch_id -> int
val save_dollar_template : gesture_id -> rw_ops -> unit result
SDL_Joystick
module Hat : sig ... end
module Joystick_power_level : sig ... end
Joystick power level ( 2.04.0 )
module Joystick_type : sig ... end
val joystick_close : joystick -> unit
val joystick_current_power_level : joystick -> Joystick_power_level.t
SDL_JoystickCurrentPowerLevel ( 2.04.0 )
val joystick_from_instance_id : joystick_id -> joystick
SDL_JoystickFromInstanceId ( 2.04.0 )
val joystick_get_device_instance_id : int -> joystick_id
( 2.06.0 )
val joystick_get_device_product : int -> int16
( 2.06.0 )
val joystick_get_device_product_version : int -> int16
( 2.06.0 )
val joystick_get_device_type : int -> Joystick_type.t
( 2.06.0 )
val joystick_get_device_vendor : int -> int16
( 2.06.0 )
val joystick_get_event_state : unit -> toggle_state result
SDL_JoystickEventState with SDL_QUERY.
val joystick_set_event_state : toggle_state -> toggle_state result
SDL_JoystickEventState. See also joystick_get_event_state
.
val joystick_get_attached : joystick -> bool
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_type : joystick -> Joystick_type.t
SDL_JoystickGetType ( 2.06.0)
val joystick_instance_id : joystick -> joystick_id result
val joystick_name_for_index : int -> string result
val num_joysticks : unit -> int result
SDL_GameController
module Controller : sig ... end
val game_controller_add_mapping : string -> bool result
val game_controller_add_mapping_from_file : string -> int result
SDL_GameControllerAddMappingsFromFile (SDL 2.0.2).
SDL_GameControllerAddMappingsFromFile (SDL 2.0.2).
val game_controller_close : game_controller -> unit
val game_controller_from_instance_id : joystick_id -> game_controller
SDL_GameControllerFromInstanceId ( 2.04.0 )
val game_controller_get_event_state : unit -> toggle_state result
SDL_GameControllerEventState with SDL_QUERY
val game_controller_set_event_state : toggle_state -> toggle_state result
val game_controller_get_attached : game_controller -> bool
val game_controller_get_axis : game_controller -> Controller.axis -> int16
val game_controller_get_axis_from_string : string -> Controller.axis
val game_controller_get_bind_for_axis :
game_controller ->
Controller.axis ->
Controller.button_bind
val game_controller_get_bind_for_button :
game_controller ->
Controller.button ->
Controller.button_bind
val game_controller_get_button : game_controller -> Controller.button -> uint8
val game_controller_get_button_from_string : string -> Controller.button
val game_controller_get_joystick : game_controller -> joystick result
val game_controller_get_product : game_controller -> uint16
( 2.06.0 )
val game_controller_get_product_version : game_controller -> uint16
( 2.06.0 )
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_get_vendor : game_controller -> uint16
( 2.06.0 )
val game_controller_mapping : game_controller -> string result
val game_controller_mapping_for_index : int -> 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
SDL_EventType. See Event
for constants.
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
SDL_EventState. See also get_event_state
.
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 register_event : unit -> event_type option
SDL_RegisterEvents called with 1
.
val wait_event_timeout : event option -> int -> bool
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_name : int -> string result
val haptic_new_effect : haptic -> haptic_effect -> haptic_effect_id result
val haptic_query : haptic -> int
val haptic_run_effect : haptic -> haptic_effect_id -> uint32 -> unit result
val haptic_stop_effect : haptic -> haptic_effect_id -> unit result
val haptic_update_effect :
haptic ->
haptic_effect_id ->
haptic_effect ->
unit result
val mouse_is_haptic : unit -> bool result
val num_haptics : unit -> int result
module Audio : sig ... end
val audio_init : string option -> unit result
val get_audio_driver : int -> string result
val get_num_audio_drivers : unit -> int result
type audio_device_id = uint32
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 = {
as_freq : int;
as_format : Audio.format;
as_channels : uint8;
as_silence : uint8;
as_samples : uint8;
as_size : uint32;
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
val queue_audio : audio_device_id -> ('a, 'b) bigarray -> unit result
val dequeue_audio : audio_device_id -> ('a, 'b) bigarray -> int
val get_queued_audio_size : audio_device_id -> int
val clear_queued_audio : audio_device_id -> unit
val get_ticks : unit -> uint32
val get_performance_counter : unit -> uint64
val get_performance_frequency : unit -> uint64
val get_cpu_cache_line_size : unit -> int result
SDL_HasAVX (SDL 2.0.2)
SDL_HasAVX2 (SDL 2.0.4)
val get_power_info : unit -> power_info
Everything except the following functions/categories are available.
void *
type in the interface)void *
type in the interface)