Module Tsdl.Sdl

module Sdl: sig .. end
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 Tsdl.Sdl.get_error returned.

Basics



Initialization and shutdown


module Init: sig .. end
Subsystem flags.
val init : Init.t -> unit result
SDL_Init
val init_sub_system : Init.t -> unit result
SDL_InitSubSystem
val quit : unit -> unit
SDL_Quit
val quit_sub_system : Init.t -> unit
SDL_QuitSubSystem
val was_init : Init.t option -> Init.t
SDL_WasInit

Hints


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

Errors


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

Log


module Log: sig .. end
val log : ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_Log
val log_critical : Log.category -> ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_LogCritical
val log_debug : Log.category -> ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_LogDebug
val log_error : Log.category -> ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_LogError
val log_get_priority : Log.category -> Log.priority
SDL_LogGetPriority
val log_info : Log.category -> ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_LogInfo
val log_message : Log.category ->
Log.priority -> ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_LogMessage
val log_reset_priorities : unit -> unit
SDL_LogResetPriorities
val log_set_all_priority : Log.priority -> unit
SDL_LogSetAllPriority
val log_set_priority : Log.category -> Log.priority -> unit
SDL_LogSetPriority
val log_verbose : Log.category -> ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_LogVerbose
val log_warn : Log.category -> ('b, Format.formatter, unit) Pervasives.format -> 'b
SDL_LogWarn

Version


val get_version : unit -> int * int * int
SDL_GetVersion
val get_revision : unit -> string
SDL_GetRevision
val get_revision_number : unit -> int
SDL_GetRevisionNumber

Files and IO abstraction



IO abstraction


type rw_ops 
SDL_RWops
val rw_from_file : string -> string -> rw_ops result
SDL_RWFromFile
val rw_close : rw_ops -> unit result
SDL_RWclose

Filesystem Paths


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

Video


type window 
SDL_Window

Colors


type color 
SDL_Color
module Color: sig .. end

Points


type point 
SDL_Point
module Point: sig .. end

Rectangles


type rect 
SDL_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 Tsdl.Sdl.enclose_points. Each consecutive pair in the array defines a point.
Raises Invalid_argument if the length of the array is not a multiple of 2.
val has_intersection : rect -> rect -> bool
SDL_HasIntersection
val intersect_rect : rect -> rect -> rect option
SDL_IntersectRect
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
SDL_RectEmpty
val rect_equals : rect -> rect -> bool
SDL_RectEquals
val union_rect : rect -> rect -> rect
SDL_UnionRect

Palettes


type palette 
SDL_Palette
val alloc_palette : int -> palette result
SDL_AllocPalette
val free_palette : palette -> unit
SDL_FreePalette
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
SDL_SetPaletteColors
val set_palette_colors_ba : palette ->
(int, Bigarray.int8_unsigned_elt) bigarray ->
fst:int -> unit result
See Tsdl.Sdl.set_palette_colors. Each consecutive quadruplet defines a color. The data is copied.
Raises Invalid_argument if the length of the array is not a multiple of 4.

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
SDL_CalculateGammaRamp
module Blend: sig .. end
module Pixel: sig .. end
type pixel_format 
SDL_PixelFormat
val alloc_format : Pixel.format_enum -> pixel_format result
SDL_AllocFormat
val free_format : pixel_format -> unit
SDL_FreeFormat
val get_pixel_format_name : Pixel.format_enum -> string
SDL_GetPixelFormatName
val get_pixel_format_format : pixel_format -> Pixel.format_enum
get_pixel_format_bytes_pp pf is the field format of pf.
val get_pixel_format_bits_pp : pixel_format -> int
get_pixel_format_bytes_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
SDL_GetRGB
val get_rgba : pixel_format ->
uint32 ->
uint8 * uint8 * uint8 * uint8
SDL_GetRGBA
val map_rgb : pixel_format ->
uint8 -> uint8 -> uint8 -> uint32
SDL_MapRGB
val map_rgba : pixel_format ->
uint8 ->
uint8 -> uint8 -> uint8 -> uint32
SDL_MapRGBA
val masks_to_pixel_format_enum : int ->
uint32 ->
uint32 ->
uint32 -> uint32 -> Pixel.format_enum
SDL_MasksToPixelFormatEnum
val pixel_format_enum_to_masks : Pixel.format_enum ->
(int * uint32 * uint32 * uint32 * uint32)
result
SDL_PixelFormatEnumToMasks
val set_pixel_format_palette : pixel_format -> palette -> unit result
SDL_SetPixelFormatPalette.

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


Surface


type surface 
SDL_Surface
val blit_scaled : src:surface ->
rect ->
dst:surface -> rect option -> unit result
SDL_BlitScaled
val blit_surface : src:surface ->
rect option ->
dst:surface -> rect option -> unit result
SDL_BlitSurface
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 convert_surface : surface -> pixel_format -> surface result
SDL_ConvertSurface
val convert_surface_format : surface ->
Pixel.format_enum -> surface result
SDL_ConvertSurfaceFormat
val create_rgb_surface : w:int ->
h:int ->
depth:int ->
uint32 ->
uint32 ->
uint32 -> uint32 -> surface result
SDL_CreateRGBSurface
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 Tsdl.Sdl.free_surface is called on the surface.

val fill_rect : surface ->
rect option -> uint32 -> unit result
SDL_FillRect
val fill_rects : surface ->
rect list -> uint32 -> unit result
SDL_FillRects
val fill_rects_ba : surface ->
(int32, Bigarray.int32_elt) bigarray ->
uint32 -> unit result
See Tsdl.Sdl.fill_rects. Each consecutive quadruplet defines a rectangle.
Raises Invalid_argument if the length of the array is not a multiple of 4.
val free_surface : surface -> unit
SDL_FreeSurface
val get_clip_rect : surface -> rect
SDL_GetClipRect
val get_color_key : surface -> uint32 result
SDL_GetColorKey
val get_surface_alpha_mod : surface -> uint8 result
SDL_GetSurfaceAlphaMod
val get_surface_blend_mode : surface -> Blend.mode result
SDL_GetSurfaceBlendMode
val get_surface_color_mod : surface -> (int * int * int) result
SDL_GetSurfaceColorMod
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.
Raises Invalid_argument If kind can't align with the surface pitch.

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
SDL_LoadBMP
val load_bmp_rw : rw_ops -> close:bool -> surface result
SDL_LoadBMP_RW
val lock_surface : surface -> unit result
SDL_LockSurface
val lower_blit : src:surface ->
rect ->
dst:surface -> rect -> unit result
SDL_LowerBlit
val lower_blit_scaled : src:surface ->
rect ->
dst:surface -> rect -> unit result
SDL_LowerBlitScaled
val save_bmp : surface -> string -> unit result
SDL_SaveBMP
val save_bmp_rw : surface -> rw_ops -> close:bool -> unit result
SDL_SaveBMP_RW
val set_clip_rect : surface -> rect -> bool
SDL_SetClipRect
val set_color_key : surface -> bool -> uint32 -> unit result
SDL_SetColorKey
val set_surface_alpha_mod : surface -> uint8 -> unit result
SDL_SetSurfaceAlphaMod
val set_surface_blend_mode : surface -> Blend.mode -> unit result
SDL_SetSurfaceBlendMode
val set_surface_color_mod : surface ->
uint8 -> uint8 -> uint8 -> unit result
SDL_SetSurfaceColorMod
val set_surface_palette : surface -> palette -> unit result
SDL_SetSurfacePalette

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

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

Renderers


type flip 
SDL_RendererFlip
module Flip: sig .. end
type texture 
SDL_Texture
type renderer 

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;
}
SDL_RendererInfo
val create_renderer : ?index:int ->
?flags:Renderer.flags ->
window -> renderer result
SDL_CreateRenderer
val create_software_renderer : surface -> renderer result
SDL_CreateSoftwareRenderer
val destroy_renderer : renderer -> unit
SDL_DestroyRenderer
val get_num_render_drivers : unit -> int result
SDL_GetNumRenderDrivers
val get_render_draw_blend_mode : renderer -> Blend.mode result
SDL_GetRenderDrawBlendMode
val get_render_draw_color : renderer ->
(uint8 * uint8 * uint8 * uint8)
result
SDL_GetRenderDrawColor
val get_render_driver_info : int -> renderer_info result
SDL_GetRenderDriverInfo
val get_render_target : renderer -> texture option
SDL_GetRenderTarget
val get_renderer : window -> renderer result
SDL_GetRenderer
val get_renderer_info : renderer -> renderer_info result
SDL_GetRendererInfo
val get_renderer_output_size : renderer -> (int * int) result
SDL_GetRendererOutputSize
val render_clear : renderer -> unit result
SDL_RenderClear
val render_copy : ?src:rect ->
?dst:rect ->
renderer -> texture -> unit result
SDL_RenderCopy
val render_copy_ex : ?src:rect ->
?dst:rect ->
renderer ->
texture ->
float -> point option -> flip -> unit result
SDL_RenderCopyEx
val render_draw_line : renderer -> int -> int -> int -> int -> unit result
SDL_RenderDrawLine
val render_draw_lines : renderer -> point list -> unit result
SDL_RenderDrawLines
val render_draw_lines_ba : renderer ->
(int32, Bigarray.int32_elt) bigarray -> unit result
See Tsdl.Sdl.render_draw_lines. Each consecutive pair in the array defines a point.
Raises Invalid_argument if the length of the array is not a multiple of 2.
val render_draw_point : renderer -> int -> int -> unit result
SDL_RenderDrawPoint
val render_draw_points : renderer -> point list -> unit result
SDL_RenderDrawPoints
val render_draw_points_ba : renderer ->
(int32, Bigarray.int32_elt) bigarray -> unit result
See Tsdl.Sdl.render_draw_points. Each consecutive pair in the array defines a point.
Raises Invalid_argument if the length of the array is not a multiple of 2.
val render_draw_rect : renderer -> rect option -> unit result
SDL_RenderDrawRect
val render_draw_rects : renderer -> rect list -> unit result
SDL_RenderDrawRects
val render_draw_rects_ba : renderer ->
(int32, Bigarray.int32_elt) bigarray -> unit result
See Tsdl.Sdl.render_draw_rects. Each consecutive quadruple in the array defines a rectangle.
Raises Invalid_argument if the length of the array is not a multiple of 4.
val render_fill_rect : renderer -> rect option -> unit result
SDL_RenderFillRect
val render_fill_rects : renderer -> rect list -> unit result
SDL_RenderDrawRects
val render_fill_rects_ba : renderer ->
(int32, Bigarray.int32_elt) bigarray -> unit result
See Tsdl.Sdl.render_draw_rects. Each consecutive quadruple in the array defines a rectangle.
Raises Invalid_argument if the length of the array is not a multiple of 4.
val render_get_clip_rect : renderer -> rect
SDL_RenderGetClipRect
val render_get_logical_size : renderer -> int * int
SDL_RenderGetLogicalSize
val render_get_scale : renderer -> float * float
SDL_RenderGetScale
val render_get_viewport : renderer -> rect
SDL_RenderGetViewport
val render_present : renderer -> unit
SDL_RenderPresent
val render_read_pixels : renderer ->
rect option ->
Pixel.format_enum option ->
('a, 'b) bigarray -> int -> unit result
SDL_RenderReadPixels
val render_set_clip_rect : renderer -> rect option -> unit result
SDL_RenderSetClipRect
val render_set_logical_size : renderer -> int -> int -> unit result
SDL_RenderSetLogicalSize
val render_set_scale : renderer -> float -> float -> unit result
SDL_RenderSetScale
val render_set_viewport : renderer -> rect option -> unit result
SDL_RenderSetViewport
val render_target_supported : renderer -> bool
SDL_RenderTargetSupported
val set_render_draw_blend_mode : renderer -> Blend.mode -> unit result
SDL_SetRenderDrawBlendMode
val set_render_draw_color : renderer ->
uint8 ->
uint8 -> uint8 -> uint8 -> unit result
SDL_SetRenderDrawColor
val set_render_target : renderer -> texture option -> unit result
SDL_SetRenderTarget

Textures


module Texture: sig .. end
val create_texture : renderer ->
Pixel.format_enum ->
Texture.access -> w:int -> h:int -> texture result
SDL_CreateTexture
val create_texture_from_surface : renderer -> surface -> texture result
SDL_CreateTextureFromSurface
val destroy_texture : texture -> unit
SDL_DestroyTexture
val get_texture_alpha_mod : texture -> uint8 result
SDL_GetTextureAlphaMod
val get_texture_blend_mode : texture -> Blend.mode result
SDL_GetTextureBlendMode
val get_texture_color_mod : texture ->
(uint8 * uint8 * uint8) result
SDL_GetTextureColorMod.
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.
Raises Invalid_argument If kind can't align with the texture pitch.

val query_texture : texture ->
(Pixel.format_enum * Texture.access * (int * int))
result
SDL_QueryTexture
val set_texture_alpha_mod : texture -> uint8 -> unit result
SDL_SetTextureAlphaMod
val set_texture_blend_mode : texture -> Blend.mode -> unit result
SDL_SetTextureBlendMode
val set_texture_color_mod : texture ->
uint8 -> uint8 -> uint8 -> unit result
SDL_SetTextureColorMod
val unlock_texture : texture -> unit
SDL_UnlockTexture
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
SDL_UpdateYUVTexture

Video drivers


val get_current_video_driver : unit -> string option
SDL_GetCurrentVideoDriver
val get_num_video_drivers : unit -> int result
SDL_GetNumVideoDrivers
val get_video_driver : int -> string result
SDL_GetVideoDriver
val video_init : string option -> unit result
SDL_VideoInit
val video_quit : unit -> unit
SDL_VideoQuit

Displays


type driverdata 
Note. Nothing can be done with that.
type display_mode = {
   dm_format : Pixel.format_enum;
   dm_w : int;
   dm_h : int;
   dm_refresh_rate : int option;
   dm_driverdata : driverdata option;
}
SDL_DisplayMode
val get_closest_display_mode : int -> display_mode -> display_mode option
SDL_GetClosestDisplayMode
val get_current_display_mode : int -> display_mode result
SDL_GetCurrentDisplayMode
val get_desktop_display_mode : int -> display_mode result
SDL_GetDesktopDisplayMode
val get_display_bounds : int -> rect result
SDL_GetDisplayBounds
val get_display_mode : int -> int -> display_mode result
SDL_GetDisplayMode
val get_display_name : int -> string result
SDL_GetDisplayName
val get_num_display_modes : int -> int result
SDL_GetNumDisplayModes
val get_num_video_displays : unit -> int result
SDL_GetNumVideoDisplays

Windows


module Window: sig .. end
val create_window : string ->
?x:int ->
?y:int ->
w:int -> h:int -> Window.flags -> window result
SDL_CreateWindow

x and y default to Tsdl.Sdl.Window.pos_undefined.

val create_window_and_renderer : w:int ->
h:int ->
Window.flags ->
(window * renderer) result
SDL_CreateWindowAndRenderer
val destroy_window : window -> unit
SDL_DestroyWindow
val get_window_brightness : window -> float
SDL_GetWindowBrightness
val get_window_display_index : window -> int result
SDL_GetWindowDisplayIndex
val get_window_display_mode : window -> display_mode result
SDL_GetWindowDisplayMode
val get_window_flags : window -> Window.flags
SDL_GetWindowFlags
val get_window_from_id : int -> window result
SDL_GetWindowFromID
val get_window_gamma_ramp : window ->
(gamma_ramp * gamma_ramp * gamma_ramp)
result
SDL_GetWindowGammaRamp
val get_window_grab : window -> bool
SDL_GetWindowGrab
val get_window_id : window -> int
SDL_GetWindowID
val get_window_maximum_size : window -> int * int
SDL_GetWindowMaximumSize
val get_window_minimum_size : window -> int * int
SDL_GetWindowMinimumSize
val get_window_pixel_format : window -> Pixel.format_enum
SDL_GetWindowPixelFormat
val get_window_position : window -> int * int
SDL_GetWindowPosition
val get_window_size : window -> int * int
SDL_GetWindowSize
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
SDL_GetWindowTitle
val hide_window : window -> unit
SDL_HideWindow
val maximize_window : window -> unit
SDL_MaximizeWindow
val minimize_window : window -> unit
SDL_MinimizeWindow
val raise_window : window -> unit
SDL_RaiseWindow
val restore_window : window -> unit
SDL_RestoreWindow
val set_window_bordered : window -> bool -> unit
SDL_SetWindowBordered
val set_window_brightness : window -> float -> unit result
SDL_SetWindowBrightness
val set_window_display_mode : window -> display_mode -> unit result
SDL_SetWindowDisplayMode
val set_window_fullscreen : window -> Window.flags -> unit result
SDL_SetWindowFullscreen
val set_window_gamma_ramp : window ->
gamma_ramp ->
gamma_ramp -> gamma_ramp -> unit result
SDL_SetWindowGammaRamp
val set_window_grab : window -> bool -> unit
SDL_SetWindowGrab
val set_window_icon : window -> surface -> unit
SDL_SetWindowIcon
val set_window_maximum_size : window -> w:int -> h:int -> unit
SDL_SetWindowMaximumSize
val set_window_minimum_size : window -> w:int -> h:int -> unit
SDL_SetWindowMinimumSize
val set_window_position : window -> x:int -> y:int -> unit
SDL_SetWindowPosition
val set_window_size : window -> w:int -> h:int -> unit
SDL_SetWindowSize
val set_window_title : window -> string -> unit
SDL_SetWindowTitle
val show_window : window -> unit
SDL_ShowWindow
val update_window_surface : window -> unit result
SDL_UpdateWindowSurface
val update_window_surface_rects : window -> rect list -> unit result
SDL_UpdateWindowSurfaceRects
val update_window_surface_rects_ba : window ->
(int32, Bigarray.int32_elt) bigarray -> unit result
See Tsdl.Sdl.update_window_surface_rects. Each consecutive quadruplet defines a rectangle.
Raises Invalid_argument if the length of the array is not a multiple of 4.

OpenGL contexts


type gl_context 

SDL_GLContext
module Gl: sig .. end
val gl_create_context : window -> gl_context result
SDL_GL_CreateContext
val gl_bind_texture : texture -> (float * float) result
SDL_GL_BindTexture
val gl_delete_context : gl_context -> unit
SDL_GL_DeleteContext
val gl_extension_supported : string -> bool
SDL_GL_ExtensionSupported
val gl_get_attribute : Gl.attr -> int result
SDL_GL_GetAttribute
val gl_get_current_context : unit -> gl_context result
SDL_GL_GetCurrentContext
val gl_get_drawable_size : window -> int * int
SDL_GL_GetDrawableSize
val gl_get_swap_interval : unit -> int result
SDL_GL_GetSwapInterval
val gl_make_current : window -> gl_context -> unit result
SDL_GL_MakeCurrent
val gl_set_attribute : Gl.attr -> int -> unit result
SDL_GL_SetAttribute
val gl_set_swap_interval : int -> unit result
SDL_GL_SetSwapInterval
val gl_swap_window : window -> unit
SDL_GL_SwapWindow
val gl_reset_attributes : unit -> unit
SDL_GL_ResetAttributes (SDL 2.0.2).
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
SDL_DisableScreenSaver
val enable_screen_saver : unit -> unit
SDL_EnableScreenSaver
val is_screen_saver_enabled : unit -> bool
SDL_IsScreenSaverEnabled

Message boxes


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

Clipboard


val get_clipboard_text : unit -> string result
SDL_GetClipboardText
val has_clipboard_text : unit -> bool
SDL_HasClipboardText
val set_clipboard_text : string -> unit result
SDL_SetClipboardText

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 
SDL_Scancode
module Scancode: sig .. end
Constants and enumeration for Tsdl.Sdl.scancode
type keycode = int 
SDL_Keycode
module K: sig .. end
Constants for Tsdl.Sdl.keycode
type keymod = int 
SDL_Keymod.
module Kmod: sig .. end
Constants for Tsdl.Sdl.keymod
val get_keyboard_focus : unit -> window option
SDL_GetKeyboardFocus
val get_keyboard_state : unit -> (int, Bigarray.int8_unsigned_elt) bigarray
SDL_GetKeyboardState
val get_key_from_name : string -> keycode
SDL_GetKeyFromName
val get_key_from_scancode : scancode -> keycode
SDL_GetKeyFromScancode
val get_key_name : keycode -> string
SDL_GetKeyName
val get_mod_state : unit -> keymod
SDL_GetModState
val get_scancode_from_key : keycode -> scancode
SDL_GetScancodeFromKey
val get_scancode_from_name : string -> scancode
SDL_GetScancodeFromName
val get_scancode_name : scancode -> string
SDL_GetScancodeName
val has_screen_keyboard_support : unit -> bool
SDL_HasScreenKeyboardSupport
val is_screen_keyboard_shown : window -> bool
SDL_IsScreenKeyboardShown
val is_text_input_active : unit -> bool
SDL_IsTextInputActive
val set_mod_state : keymod -> unit
SDL_SetModState
val set_text_input_rect : rect option -> unit
SDL_SetTextInputRect
val start_text_input : unit -> unit
SDL_StartTextInput
val stop_text_input : unit -> unit
SDL_StopTextInput

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
SDL_CreateColorCursor
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
SDL_CreateCursor
val create_system_cursor : System_cursor.t -> cursor result
SDL_CreateSystemCursor
val free_cursor : cursor -> unit
SDL_FreeCursor
val get_cursor : unit -> cursor option
SDL_GetCursor
val get_default_cursor : unit -> cursor option
SDL_GetDefaultCursor
val get_mouse_focus : unit -> window option
SDL_GetMouseFocus
val get_mouse_state : unit -> uint32 * (int * int)
SDL_GetMouseState
val get_relative_mouse_mode : unit -> bool
SDL_GetRelativeMouseMode
val get_relative_mouse_state : unit -> uint32 * (int * int)
SDL_GetRelativeMouseState
val get_cursor_shown : unit -> bool result
SDL_ShowCursor with SDL_QUERY.
val set_cursor : cursor option -> unit
SDL_SetCursor
val set_relative_mouse_mode : bool -> unit result
SDL_SetRelativeMouseMode
val show_cursor : bool -> bool result
SDL_ShowCursor. See also Tsdl.Sdl.get_cursor_shown.
val warp_mouse_in_window : window option -> x:int -> y:int -> unit
SDL_WarpMouseInWindow

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
SDL_GetNumTouchDevices.
val get_num_touch_fingers : touch_id -> int
SDL_GetNumTouchFingers.
val get_touch_device : int -> touch_id result
SDL_GetTouchDevice.
val get_touch_finger : touch_id -> int -> finger option
SDL_GetTouchFinger.
val load_dollar_templates : touch_id -> rw_ops -> unit result
SDL_LoadDollarTemplates
val record_gesture : touch_id -> unit result
SDL_RecordGesture.
val save_dollar_template : gesture_id -> rw_ops -> unit result
SDL_SaveDollarTemplate.
val save_all_dollar_templates : rw_ops -> unit result
SDL_SaveAllDollarTemplate.

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
SDL_JoystickClose
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 Tsdl.Sdl.joystick_get_event_state.
val joystick_get_attached : joystick -> bool
SDL_JoystickGetAttached
val joystick_get_axis : joystick -> int -> int16
SDL_JoystickGetAxis
val joystick_get_ball : joystick -> int -> (int * int) result
SDL_JoystickGetBall
val joystick_get_button : joystick -> int -> uint8
SDL_JoystickGetButton
val joystick_get_device_guid : int -> joystick_guid
SDL_JoystickGetDeviceGUID
val joystick_get_guid : joystick -> joystick_guid
SDL_JoystickGetGUID
val joystick_get_guid_from_string : string -> joystick_guid
SDL_JoystickGetGUIDFromString
val joystick_get_guid_string : joystick_guid -> string
SDL_JoystickGetGUIDString
val joystick_get_hat : joystick -> int -> Hat.t
SDL_JoystickGetHat
val joystick_instance_id : joystick -> joystick_id result
SDL_JoystickInstanceID
val joystick_name : joystick -> string result
SDL_JoystickName
val joystick_name_for_index : int -> string result
SDL_JoystickNameForIndex
val joystick_num_axes : joystick -> int result
SDL_JoystickNumAxes
val joystick_num_balls : joystick -> int result
SDL_JoystickNumBalls
val joystick_num_buttons : joystick -> int result
SDL_JoystickNumButtons
val joystick_num_hats : joystick -> int result
SDL_JoystickNumHats
val joystick_open : int -> joystick result
SDL_JoystickOpen
val joystick_update : unit -> unit
SDL_JoystickUpdate
val num_joysticks : unit -> int result
SDL_NumJoysticks

Game controller


type game_controller 

SDL_GameController
module Controller: sig .. end
val game_controller_add_mapping : string -> bool result
SDL_GameControllerAddMapping
val game_controller_add_mapping_from_file : string -> int result
SDL_GameControllerAddMappingsFromFile (SDL 2.0.2).
val game_controller_add_mapping_from_rw : rw_ops -> bool -> int result
SDL_GameControllerAddMappingsFromFile (SDL 2.0.2).
val game_controller_close : game_controller -> unit
SDL_GameControllerClose
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
SDL_GameControllerEventState. See also Tsdl.Sdl.game_controller_get_event_state.
val game_controller_get_attached : game_controller -> bool
SDL_GameControllerGetAttached
val game_controller_get_axis : game_controller -> Controller.axis -> int16
SDL_GameControllerGetAxis
val game_controller_get_axis_from_string : string -> Controller.axis
SDL_GameControllerGetAxisFromString
val game_controller_get_bind_for_axis : game_controller ->
Controller.axis -> Controller.button_bind
SDL_GameControllerGetBindForAxis
val game_controller_get_bind_for_button : game_controller ->
Controller.button -> Controller.button_bind
SDL_GameControllerGetBindForButton
val game_controller_get_button : game_controller -> Controller.button -> uint8
SDL_GameControllerGetButton
val game_controller_get_button_from_string : string -> Controller.button
SDL_GameControllerGetButtonFromString
val game_controller_get_joystick : game_controller -> joystick result
SDL_GameControllerGetJoystick
val game_controller_get_string_for_axis : Controller.axis -> string option
SDL_GameControllerGetStringForAxis
val game_controller_get_string_for_button : Controller.button -> string option
SDL_GameControllerGetStringForButton
val game_controller_mapping : game_controller -> string result
SDL_GameControllerMapping
val game_controller_mapping_for_guid : joystick_guid -> string result
SDL_GameControllerMappingForGUID
val game_controller_name : game_controller -> string result
SDL_GameControllerName
val game_controller_name_for_index : int -> string result
SDL_GameControllerNameForIndex
val game_controller_open : int -> game_controller result
SDL_GameControllerOpen
val game_controller_update : unit -> unit
SDL_GameControllerUpdate
val is_game_controller : int -> bool
SDL_IsGameController

Events


type event_type = int 
SDL_EventType. See Tsdl.Sdl.Event for constants.
type event 
SDL_Event
module Event: sig .. end
Event accessors and Tsdl.Sdl.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 Tsdl.Sdl.get_event_state.
val flush_event : event_type -> unit
SDL_FlushEvent
val flush_events : event_type -> event_type -> unit
SDL_FlushEvents
val has_event : event_type -> bool
SDL_HasEvent
val has_events : event_type -> event_type -> bool
SDL_HasEvents
val poll_event : event option -> bool
SDL_PollEvent
val pump_events : unit -> unit
SDL_PumpEvents
val push_event : event -> bool result
SDL_PushEvent
val register_event : unit -> event_type option
SDL_RegisterEvents called with 1.
val wait_event : event option -> unit result
SDL_WaitEvent
val wait_event_timeout : event option -> int -> bool
SDL_WaitEventTimeout

Force Feedback


type haptic 
type haptic_effect 
type haptic_effect_id 
module Haptic: sig .. end
val haptic_close : haptic -> unit
SDL_HapticClose
val haptic_destroy_effect : haptic -> haptic_effect_id -> unit
SDL_HapticDestroyEffect
val haptic_effect_supported : haptic -> haptic_effect -> bool result
SDL_HapticEffectSupported
val haptic_get_effect_status : haptic -> haptic_effect_id -> bool result
SDL_HapticGetEffectStatus
val haptic_index : haptic -> int result
SDL_HapticIndex
val haptic_name : int -> string result
SDL_HapticName
val haptic_new_effect : haptic ->
haptic_effect -> haptic_effect_id result
SDL_HapticNewEffect
val haptic_num_axes : haptic -> int result
SDL_HapticNumAxes
val haptic_num_effects : haptic -> int result
SDL_HapticNumEffects
val haptic_num_effects_playing : haptic -> int result
SDL_HapticNumEffectsPlaying
val haptic_open : int -> haptic result
SDL_HapticOpen
val haptic_open_from_joystick : joystick -> haptic result
SDL_HapticOpenFromJoystick
val haptic_open_from_mouse : unit -> haptic result
SDL_HapticOpenFromMouse
val haptic_opened : int -> bool
SDL_HapticOpened
val haptic_pause : haptic -> unit result
SDL_HapticPause
val haptic_query : haptic -> int
SDL_HapticQuery
val haptic_rumble_init : haptic -> unit result
SDL_HapticRumbleInit
val haptic_rumble_play : haptic -> float -> uint32 -> unit result
SDL_HapticRumblePlay
val haptic_rumble_stop : haptic -> unit result
SDL_HapticRumbleStop
val haptic_rumble_supported : haptic -> bool result
SDL_HapticRumbleSupported
val haptic_run_effect : haptic ->
haptic_effect_id -> uint32 -> unit result
SDL_HapticRunEffect
val haptic_set_autocenter : haptic -> int -> unit result
SDL_HapticSetAutocenter
val haptic_set_gain : haptic -> int -> unit result
SDL_HapticSetGain
val haptic_stop_all : haptic -> unit result
SDL_HapticStopAll
val haptic_stop_effect : haptic -> haptic_effect_id -> unit result
SDL_HapticStopEffect
val haptic_unpause : haptic -> unit result
SDL_HapticUnpause
val haptic_update_effect : haptic ->
haptic_effect_id -> haptic_effect -> unit result
SDL_HapticUpdateEffect
val joystick_is_haptic : joystick -> bool result
SDL_JoystickIsHaptic
val mouse_is_haptic : unit -> bool result
SDL_MouseIsHaptic
val num_haptics : unit -> int result
SDL_NumHaptics

Audio


module Audio: sig .. end

Audio drivers


val audio_init : string option -> unit result
SDL_AudioInit
val audio_quit : unit -> unit
SDL_AudioQuit
val get_audio_driver : int -> string result
SDL_GetAudioDriver
val get_current_audio_driver : unit -> string option
SDL_GetCurrentAudioDriver
val get_num_audio_drivers : unit -> int result
SDL_GetNumAudioDrivers

Audio devices


type audio_device_id 
type ('a, 'b) audio_spec = {
   as_freq : int;
   as_format : Audio.format;
   as_channels : uint8;
   as_silence : uint8;
   as_samples : uint8;
   as_size : uint32;
   as_ba_kind : ('a, 'b) Bigarray.kind;
   as_callback : (('a, 'b) bigarray -> unit) option;
}
SDL_AudioSpec
val close_audio_device : audio_device_id -> unit
SDL_CloseAudioDevice
val free_wav : ('a, 'b) bigarray -> unit
SDL_FreeWAV.
val get_audio_device_name : int -> bool -> string result
SDL_GetAudioDeviceName
val get_audio_device_status : audio_device_id -> Audio.status
SDL_GetAudioDeviceStatus
val get_num_audio_devices : bool -> int result
SDL_GetNumAudioDevices
val load_wav_rw : rw_ops ->
('a, 'b) audio_spec ->
(('a, 'b) audio_spec * ('a, 'b) bigarray) result
SDL_LoadWAV_RW.
val lock_audio_device : audio_device_id -> unit
SDL_LockAudioDevice
val open_audio_device : string option ->
bool ->
('a, 'b) audio_spec ->
Audio.allow ->
(audio_device_id * ('a, 'b) audio_spec) result
SDL_OpenAudioDevice
val pause_audio_device : audio_device_id -> bool -> unit
SDL_PauseAudioDevice
val unlock_audio_device : audio_device_id -> unit
SDL_UnlockAudioDevice

Timer


val delay : uint32 -> unit
SDL_Delay
val get_ticks : unit -> uint32
SDL_GetTicks
val get_performance_counter : unit -> uint64
SDL_GetPerformanceCounter
val get_performance_frequency : unit -> uint64
SDL_GetPerformanceFrequency

Platform and CPU information


val get_platform : unit -> string
SDL_GetPlatform
val get_cpu_cache_line_size : unit -> int result
SDL_GetCPUCacheLineSize
val get_cpu_count : unit -> int
SDL_GetCPUCount
val get_system_ram : unit -> int
SDL_GetSystemRAM
val has_3d_now : unit -> bool
SDL_Has3DNow
val has_altivec : unit -> bool
SDL_HasAltiVec
val has_avx : unit -> bool
SDL_HasAVX (SDL 2.0.2)
val has_mmx : unit -> bool
SDL_HasMMX
val has_rdtsc : unit -> bool
SDL_HasRDTSC
val has_sse : unit -> bool
SDL_HasSSE
val has_sse2 : unit -> bool
SDL_HasSSE2
val has_sse3 : unit -> bool
SDL_HasSSE3
val has_sse41 : unit -> bool
SDL_HasSSE41
val has_sse42 : unit -> bool
SDL_HasSSE42

Power


type power_state = [ `Charged | `Charging | `No_battery | `On_battery | `Unknown ] 
SDL_PowerState
type power_info = {
   pi_state : power_state;
   pi_secs : int option;
   pi_pct : int option;
}
val get_power_info : unit -> power_info
SDL_GetPowerInfo

Binding Coverage

Everything except the following functions/categories are available.

Unbound categories

Unbound functions