pub unsafe fn init() -> Result<SDLToken, String> {
  if I_THINK_THAT_SDL2_IS_ACTIVE.swap(true, Ordering::SeqCst) {
    // Note(Lokathor): `swap` gives the old value back, so if we get back `true`
    // that means it was already active, so that's an error.
    Err("The library is currently initialized!".to_string())
  } else if SDL_Init(SDL_INIT_EVERYTHING) == 0 {
    Ok(SDLToken {
      _marker: PhantomData,
    })
  } else {
    let out = get_error();
    I_THINK_THAT_SDL2_IS_ACTIVE.store(false, Ordering::SeqCst);
    Err(out)
  }
}
/// Initializes SDL2 and gives you a token as proof, or an error message.
///
/// # Failure
///
/// * You cannot double initialize SDL2, you'll get an error.
/// * If SDL2 fails to initialize you'll get an error and it will revert itself
///   to an uninitialized state, perhaps allowing you to try again.
///
/// # Safety
///
/// * This can only be called from the main thread (because of a
///   [macOS](https://tinyurl.com/y5bv7g4v) limit built into Cocoa).
Initializes SDL2 and gives you a token as proof, or an error message.
Initializes SDL2 and gives you a token as proof or an error message .
pub unsafe fn init() -> Result<SDLToken, String> {
  if I_THINK_THAT_SDL2_IS_ACTIVE.swap(true, Ordering::SeqCst) {
    // Note(Lokathor): `swap` gives the old value back, so if we get back `true`
    // that means it was already active, so that's an error.
    Err("The library is currently initialized!".to_string())
  } else if SDL_Init(SDL_INIT_EVERYTHING) == 0 {
    Ok(SDLToken {
      _marker: PhantomData,
    })
  } else {
    let out = get_error();
    I_THINK_THAT_SDL2_IS_ACTIVE.store(false, Ordering::SeqCst);
    Err(out)
  }
}
pub unsafe fn init ( ) -> Result < SDLToken , String > { if I_THINK_THAT_SDL2_IS_ACTIVE . swap ( true , Ordering :: SeqCst ) { // Note(Lokathor): `swap` gives the old value back, so if we get back `true` // that means it was already active, so that's an error. Err ( " " . to_string ( ) ) } else if SDL_Init ( SDL_INIT_EVERYTHING ) == 0 { Ok ( SDLToken { _marker : PhantomData , } ) } else { let out = get_error ( ) ; I_THINK_THAT_SDL2_IS_ACTIVE . store ( false , Ordering :: SeqCst ) ; Err ( out ) } }
Initializes SDL2 and gives you a token as proof, or an error message.
Initializes SDL2 and gives you a token as proof or an error message .
failure
You cannot double initialize SDL2, you'll get an error.
If SDL2 fails to initialize you'll get an error and it will revert itself
to an uninitialized state, perhaps allowing you to try again.
You cannot double initialize SDL2 you ' ll get an error . If SDL2 fails to initialize you ' ll get an error and it will revert itself to an uninitialized state perhaps allowing you to try again .
safety
This can only be called from the main thread (because of a
[macOS] limit built into Cocoa).
This can only be called from the main thread ( because of a [ macOS ] limit built into Cocoa ) .