Initialization and Shutdown

Subsystem Flags

csdl2.SDL_INIT_TIMER

Timer subsystem.

csdl2.SDL_INIT_AUDIO

Audio subsystem.

csdl2.SDL_INIT_VIDEO

Video subsystem. (Implies SDL_INIT_EVENTS)

csdl2.SDL_INIT_JOYSTICK

Joystick subsystem. (Implies SDL_INIT_EVENTS)

csdl2.SDL_INIT_HAPTIC

Haptic (force feedback) subsystem.

csdl2.SDL_INIT_GAMECONTROLLER

Controller subsystem. (Implies SDL_INIT_JOYSTICK)

csdl2.SDL_INIT_EVENTS

Events subsystem.

csdl2.SDL_INIT_EVERYTHING

Initialize all subsystems.

csdl2.SDL_INIT_NOPARACHUTE

This flag is provided for compatibility and is ignored.

Initialization

csdl2.SDL_Init(flags)

Initializes the SDL library. This must be called before using any other SDL function.

Parameters:flags (int) – Subsystem Flags of subsystems to initialize, OR’d together.
csdl2.SDL_InitSubSystem(flags)

Initialize specific subsystems.

Subsystem initialization is ref-counted. You must call SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or call SDL_Quit() to force a shutdown). If a subsystem is already loaded then this call will increase the refcount and return.

Parameters:flags (int) – Subsystem Flags of subsystems to initialize, OR’d together.
csdl2.SDL_WasInit(flags) → int

Return a mask of the specified subsystems which have previously been initialized.

Parameters:flags (int) – Subsystem Flags of subsystems to query, OR’d together.
Returns:The initialization status of the specified subsystems, or a mask of all initialized subsystems if flags is 0.

Shutdown

csdl2.SDL_QuitSubSystem(flags)

Shut down specific subsystems.

Subsystem initialization is ref-counted. SDL_QuitSubSystem() will decrement the refcount for each of the specified subsystems, and if the refcount of a subsystem reached 0 that subsystem is shut down.

Parameters:flags (int) – Subsystem Flags of subsystems to shut down, OR’d together.

Note

If you start a subsystem using a call to that subsystem’s init function (e.g. SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(), SDL_QuitSubSystem() will not work. You will need to use that subsystem’s quit function (e.g. SDL_VideoQuit()) directly instead.

Note

You still need to call SDL_Quit() even if you close all open subsystems with SDL_QuitSubSystem().

csdl2.SDL_Quit()

Clean up all initialized subsystems. This function should be called upon all exit conditions.

Note

This function should be called even if all initialized subsystems have been shut down with SDL_QuitSubSystem().

Note

It is safe to call this function even in the case of errors in initialization.

Note

If a subsystem is started using a call to that subsystem’s init function (e.g. SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(), then the subsystem’s quit function (e.g. SDL_VideoQuit()) must be called to shut the subsystem down before calling SDL_Quit().