Holds the global methods of sdl2

Introduced properties

fun clear_error

sdl2 :: SDL :: clear_error

Clear the SDL error
fun cpu_count: Int

sdl2 :: SDL :: cpu_count

The number of CPU on the system
fun error: CString

sdl2 :: SDL :: error

Returns the latest SDL error
fun img: IMG

sdl2 :: SDL :: img

Access to the global methods of sdl2::image
protected fun img=(img: IMG)

sdl2 :: SDL :: img=

Access to the global methods of sdl2::image
fun initialize(subsystems: SDLInitFlags): Bool

sdl2 :: SDL :: initialize

Initialize the given SDL subsystems, returns false on error
fun initialized_subsystems(subsystems: SDLInitFlags): SDLInitFlags

sdl2 :: SDL :: initialized_subsystems

What SDL subsystems are initialized? You can use a mask of subsystems to restrict the query.
init internal

sdl2 :: SDL :: internal

TODO make this private and only called through sys.sdl
init new: SDL

sdl2 :: SDL :: new

Get the SDL singleton
fun quit

sdl2 :: SDL :: quit

Quit SDL
fun relative_mouse_mode: Bool

sdl2 :: SDL :: relative_mouse_mode

Hide cursor and collect only relative mouse events?
fun relative_mouse_mode=(value: Bool)

sdl2 :: SDL :: relative_mouse_mode=

Collect only relative mouse events and hide cursor
fun set_main_ready

sdl2 :: SDL :: set_main_ready

Function that should be called from the SDL main method
fun show_cursor: Bool

sdl2 :: SDL :: show_cursor

Is the cursor visible?
fun show_cursor=(val: Bool)

sdl2 :: SDL :: show_cursor=

Show or hide the cursor
fun show_simple_message_box(level: SDLMessageBoxFlags, title: CString, content: CString)

sdl2 :: SDL :: show_simple_message_box

Show a simple message box
fun system_ram: Int

sdl2 :: SDL :: system_ram

Amount of RAM configured on the system
fun was_initialized: Bool

sdl2 :: SDL :: was_initialized

Was SDL initialized?

Redefined properties

redef type SELF: SDL

sdl2 $ SDL :: SELF

Type of this instance, automatically specialized in every class
redef fun finalize

sdl2 $ SDL :: finalize

Liberate any resources held by self before the memory holding self is freed

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun clear_error

sdl2 :: SDL :: clear_error

Clear the SDL error
fun cpu_count: Int

sdl2 :: SDL :: cpu_count

The number of CPU on the system
fun error: CString

sdl2 :: SDL :: error

Returns the latest SDL error
fun finalize

core :: Finalizable :: finalize

Liberate any resources held by self before the memory holding self is freed
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun img: IMG

sdl2 :: SDL :: img

Access to the global methods of sdl2::image
protected fun img=(img: IMG)

sdl2 :: SDL :: img=

Access to the global methods of sdl2::image
init init

core :: Object :: init

fun initialize(subsystems: SDLInitFlags): Bool

sdl2 :: SDL :: initialize

Initialize the given SDL subsystems, returns false on error
fun initialized_subsystems(subsystems: SDLInitFlags): SDLInitFlags

sdl2 :: SDL :: initialized_subsystems

What SDL subsystems are initialized? You can use a mask of subsystems to restrict the query.
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
init internal

sdl2 :: SDL :: internal

TODO make this private and only called through sys.sdl
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
init new: SDL

sdl2 :: SDL :: new

Get the SDL singleton
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun quit

sdl2 :: SDL :: quit

Quit SDL
fun relative_mouse_mode: Bool

sdl2 :: SDL :: relative_mouse_mode

Hide cursor and collect only relative mouse events?
fun relative_mouse_mode=(value: Bool)

sdl2 :: SDL :: relative_mouse_mode=

Collect only relative mouse events and hide cursor
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun set_main_ready

sdl2 :: SDL :: set_main_ready

Function that should be called from the SDL main method
fun show_cursor: Bool

sdl2 :: SDL :: show_cursor

Is the cursor visible?
fun show_cursor=(val: Bool)

sdl2 :: SDL :: show_cursor=

Show or hide the cursor
fun show_simple_message_box(level: SDLMessageBoxFlags, title: CString, content: CString)

sdl2 :: SDL :: show_simple_message_box

Show a simple message box
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun system_ram: Int

sdl2 :: SDL :: system_ram

Amount of RAM configured on the system
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun was_initialized: Bool

sdl2 :: SDL :: was_initialized

Was SDL initialized?
package_diagram sdl2::SDL SDL core::Finalizable Finalizable sdl2::SDL->core::Finalizable core::Object Object core::Finalizable->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

class Finalizable

core :: Finalizable

An object needing finalization

Class definitions

sdl2 $ SDL
# 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

sdl2 :: image $ SDL
redef class SDL
	# Access to the global methods of `sdl2::image`
	var img = new IMG is lazy
end
lib/sdl2/image.nit:32,1--35,3