pub struct Sdl { /* private fields */ }
Expand description
The SDL context type. Initialize with sdl2::init()
.
From a thread-safety perspective, Sdl
represents the main thread.
As such, Sdl
is a useful type for ensuring that SDL types that can only
be used on the main thread are initialized that way.
For instance, SDL_PumpEvents()
is not thread safe, and may only be
called on the main thread.
All functionality that calls SDL_PumpEvents()
is thus put into an
EventPump
type, which can only be obtained through Sdl
.
This guarantees that the only way to call event-pumping functions is on
the main thread.
Implementations§
source§impl Sdl
impl Sdl
sourcepub fn audio(&self) -> Result<AudioSubsystem, String>
pub fn audio(&self) -> Result<AudioSubsystem, String>
Initializes the audio subsystem.
sourcepub fn event(&self) -> Result<EventSubsystem, String>
pub fn event(&self) -> Result<EventSubsystem, String>
Initializes the event subsystem.
sourcepub fn joystick(&self) -> Result<JoystickSubsystem, String>
pub fn joystick(&self) -> Result<JoystickSubsystem, String>
Initializes the joystick subsystem.
sourcepub fn haptic(&self) -> Result<HapticSubsystem, String>
pub fn haptic(&self) -> Result<HapticSubsystem, String>
Initializes the haptic subsystem.
sourcepub fn game_controller(&self) -> Result<GameControllerSubsystem, String>
pub fn game_controller(&self) -> Result<GameControllerSubsystem, String>
Initializes the game controller subsystem.
sourcepub fn sensor(&self) -> Result<SensorSubsystem, String>
pub fn sensor(&self) -> Result<SensorSubsystem, String>
Initializes the game controller subsystem.
sourcepub fn timer(&self) -> Result<TimerSubsystem, String>
pub fn timer(&self) -> Result<TimerSubsystem, String>
Initializes the timer subsystem.
sourcepub fn video(&self) -> Result<VideoSubsystem, String>
pub fn video(&self) -> Result<VideoSubsystem, String>
Initializes the video subsystem.
sourcepub fn event_pump(&self) -> Result<EventPump, String>
pub fn event_pump(&self) -> Result<EventPump, String>
Obtains the SDL event pump.
At most one EventPump
is allowed to be alive during the program’s execution.
If this function is called while an EventPump
instance is alive, the function will return
an error.