Struct sdl2::Sdl [] [src]

pub struct Sdl {
    // some fields omitted
}

The SDL context type. Initialize with sdl2::init().

From a thread-safety perspective, Sdl represents the main thread. Only one instance of Sdl is allowed per process, and cannot be moved or used across non-main threads.

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.

Methods

impl Sdl

fn keyboard(&self) -> KeyboardUtil

impl Sdl

fn mouse(&self) -> MouseUtil

impl Sdl

fn new() -> SdlResult<Sdl>

fn audio(&self) -> SdlResult<AudioSubsystem>

Initializes the audio subsystem.

fn event(&self) -> SdlResult<EventSubsystem>

Initializes the event subsystem.

fn joystick(&self) -> SdlResult<JoystickSubsystem>

Initializes the joystick subsystem.

fn haptic(&self) -> SdlResult<HapticSubsystem>

Initializes the haptic subsystem.

fn game_controller(&self) -> SdlResult<GameControllerSubsystem>

Initializes the game controller subsystem.

fn timer(&self) -> SdlResult<TimerSubsystem>

Initializes the timer subsystem.

fn video(&self) -> SdlResult<VideoSubsystem>

Initializes the video subsystem.

fn event_pump(&self) -> SdlResult<EventPump>

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.