sdl2
sdl2 :: SDL :: defaultinit
sdl2 :: SDL :: initialize
Initialize the given SDLsubsystems
, returns false
on error
sdl2 :: SDL :: initialized_subsystems
What SDL subsystems are initialized? You can use a mask ofsubsystems
to restrict the query.
sdl2 :: SDL :: relative_mouse_mode
Hide cursor and collect only relative mouse events?sdl2 :: SDL :: relative_mouse_mode=
Collect only relative mouse events and hide cursorsdl2 :: SDL :: set_main_ready
Function that should be called from the SDL main methodsdl2 :: SDL :: show_simple_message_box
Show a simple message boxcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Finalizable :: defaultinit
core :: Object :: defaultinit
sdl2 :: SDL :: defaultinit
core :: Finalizable :: finalize
Liberate any resources held byself
before the memory holding self
is freed
sdl2 :: SDL :: initialize
Initialize the given SDLsubsystems
, returns false
on error
sdl2 :: SDL :: initialized_subsystems
What SDL subsystems are initialized? You can use a mask ofsubsystems
to restrict the query.
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).sdl2 :: SDL :: relative_mouse_mode
Hide cursor and collect only relative mouse events?sdl2 :: SDL :: relative_mouse_mode=
Collect only relative mouse events and hide cursorsdl2 :: SDL :: set_main_ready
Function that should be called from the SDL main methodsdl2 :: SDL :: show_simple_message_box
Show a simple message box
# 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