Module init
dep_sdl3
only.Expand description
All SDL programs need to initialize the library before starting to work with it.
Almost everything can simply call SDL_Init()
near startup, with a handful
of flags to specify subsystems to touch. These are here to make sure SDL
does not even attempt to touch low-level pieces of the operating system
that you don’t intend to use. For example, you might be using SDL for video
and input but chose an external library for audio, and in this case you
would just need to leave off the SDL_INIT_AUDIO
flag to make sure that
external library has complete control.
Most apps, when terminating, should call SDL_Quit()
. This will clean up
(nearly) everything that SDL might have allocated, and crucially, it’ll
make sure that the display’s resolution is back to what the user expects if
you had previously changed it for your game.
SDL3 apps are strongly encouraged to call SDL_SetAppMetadata()
at startup
to fill in details about the program. This is completely optional, but it
helps in small ways (we can provide an About dialog box for the macOS menu,
we can name the app in the system’s audio mixer, etc). Those that want to
provide a lot of information should look at the more-detailed
SDL_SetAppMetadataProperty()
.
Structs§
- SDL_
AppResult - Return values for optional main callbacks.
Constants§
- SDL_
APP_ CONTINUE - Value that requests that the app continue from the main callbacks.
- SDL_
APP_ FAILURE - Value that requests termination with error from the main callbacks.
- SDL_
APP_ SUCCESS - Value that requests termination with success from the main callbacks.
- SDL_
INIT_ AUDIO SDL_INIT_AUDIO
impliesSDL_INIT_EVENTS
- SDL_
INIT_ CAMERA SDL_INIT_CAMERA
impliesSDL_INIT_EVENTS
- SDL_
INIT_ EVENTS - SDL_
INIT_ GAMEPAD SDL_INIT_GAMEPAD
impliesSDL_INIT_JOYSTICK
- SDL_
INIT_ HAPTIC - SDL_
INIT_ JOYSTICK SDL_INIT_JOYSTICK
impliesSDL_INIT_EVENTS
, should be initialized on the same thread asSDL_INIT_VIDEO
on Windows if you don’t set [SDL_HINT_JOYSTICK_THREAD
]- SDL_
INIT_ SENSOR SDL_INIT_SENSOR
impliesSDL_INIT_EVENTS
- SDL_
INIT_ VIDEO SDL_INIT_VIDEO
impliesSDL_INIT_EVENTS
, should be initialized on the main thread- SDL_
PROP_ APP_ METADATA_ COPYRIGHT_ STRING - SDL_
PROP_ APP_ METADATA_ CREATOR_ STRING - SDL_
PROP_ APP_ METADATA_ IDENTIFIER_ STRING - SDL_
PROP_ APP_ METADATA_ NAME_ STRING - SDL_
PROP_ APP_ METADATA_ TYPE_ STRING - SDL_
PROP_ APP_ METADATA_ URL_ STRING - SDL_
PROP_ APP_ METADATA_ VERSION_ STRING
Functions§
- SDL_
GetApp ⚠Metadata Property - Get metadata about your app.
- SDL_
Init ⚠ - Initialize the SDL library.
- SDL_
Init ⚠SubSystem - Compatibility function to initialize the SDL library.
- SDL_
IsMain ⚠Thread - Return whether this is the main thread.
- SDL_
Quit ⚠ - Clean up all initialized subsystems.
- SDL_
Quit ⚠SubSystem - Shut down specific SDL subsystems.
- SDL_
RunOn ⚠Main Thread - Call a function on the main thread during event processing.
- SDL_
SetApp ⚠Metadata - Specify basic metadata about your app.
- SDL_
SetApp ⚠Metadata Property - Specify metadata about your app through a set of properties.
- SDL_
WasInit ⚠ - Get a mask of the specified subsystems which are currently initialized.
Type Aliases§
- SDL_
AppEvent_ func - Function pointer typedef for [
SDL_AppEvent
]. - SDL_
AppInit_ func - Function pointer typedef for [
SDL_AppInit
]. - SDL_
AppIterate_ func - Function pointer typedef for [
SDL_AppIterate
]. - SDL_
AppQuit_ func - Function pointer typedef for [
SDL_AppQuit
]. - SDL_
Init Flags - Initialization flags for
SDL_Init
and/orSDL_InitSubSystem
- SDL_
Main Thread Callback - Callback run on the main thread.