sdl2 :: SDL :: defaultinit
# Holds the global methods of `sdl2`
class SDL
	super Finalizable
	# Get the `SDL` singleton
	new do return once new SDL.internal
	# TODO make this private and only called through `sys.sdl`
	init internal do end
	# Initialize the given SDL `subsystems`, returns `false` on error
	fun initialize(subsystems: SDLInitFlags): Bool `{ return SDL_Init(subsystems) == 0; `}
	# Returns the latest SDL error
	#
	# After calling this method, you should also call `clear_error`.
	fun error: CString `{ return (char*)SDL_GetError(); `}
	# Clear the SDL error
	fun clear_error `{ SDL_ClearError(); `}
	# Quit SDL
	fun quit `{ SDL_Quit(); `}
	# Was SDL initialized?
	fun was_initialized: Bool do return not initialized_subsystems((new SDLInitFlags).everything).is_empty
	# What SDL subsystems are initialized? You can use a mask of `subsystems` to restrict the query.
	#
	# Returns the flags of the initialized subsystems.
	fun initialized_subsystems(subsystems: SDLInitFlags): SDLInitFlags `{ return SDL_WasInit(subsystems); `}
	# The number of CPU on the system
	fun cpu_count: Int `{ return SDL_GetCPUCount(); `}
	# Amount of RAM configured on the system
	fun system_ram: Int `{ return SDL_GetSystemRAM(); `}
	# Show a simple message box
	fun show_simple_message_box(level: SDLMessageBoxFlags, title, content: CString) `{
		SDL_ShowSimpleMessageBox(level, title, content, NULL);
	`}
	redef fun finalize do if was_initialized then quit
	# Function that should be called from the SDL main method
	#
	# This method should not normally be used, refer to the SDL source code
	# before use.
	fun set_main_ready `{ SDL_SetMainReady(); `}
	# Show or hide the cursor
	fun show_cursor=(val: Bool) `{ SDL_ShowCursor(val? SDL_ENABLE: SDL_DISABLE); `}
	# Is the cursor visible?
	fun show_cursor: Bool `{ return SDL_ShowCursor(SDL_QUERY); `}
	# Collect only relative mouse events and hide cursor
	#
	# Check `relative_mouse_mode` to see if the mode could be applied,
	# if not, see `error`.
	fun relative_mouse_mode=(value: Bool) `{
		SDL_SetRelativeMouseMode(value);
	`}
	# Hide cursor and collect only relative mouse events?
	fun relative_mouse_mode: Bool `{
		return SDL_GetRelativeMouseMode();
	`}
end
					lib/sdl2/sdl2_base.nit:29,1--98,3