- Changed 'while' loops into 'loop'-type loops with a lifetime, thus eliminating 'running' variable
- Moved 'use' statements out of the loop (one time is enought)
* The `keycode` and `scancode` modules only contained a single enum each, so
it makes more sense to put them into the `keyboard` module.
* KeyCode -> Keycode, ScanCode -> Scancode.
A small detail, but this is consistent with SDL_Keycode and SDL_Scancode.
* Window::new, Window::new_with_init and WindowFlags have been
removed completely.
* Renderer::new_with_window has been removed, as it uses the old
WindowFlags pattern.
To update, use the window builder with Renderer::from_window.
All Window properties must be accessed using `Window::properties`,
which requires a reference to the event pump.
If the event pump is not being used (mutably), then the caller can
obtain a shared reference to it, which means the event pump cannot
mutate the Window.
Renderer also has a way to access window properties, using
`Renderer::window::properties`.
Additionally, Window initialization requires an `Sdl` reference.
Because `Sdl` is `!Send` and `!Sync`, obtaining a `Sdl` reference is
only possible on the same thread.
* Change to crates.io rand in examples/whitenoise
* Change #[feature(io, path)] to #[feature(old_io, old_path)] everywhere
* Take away the `us` suffix everywhere
* Switch from `c_str_to_bytes` to `CStr::from_ptr(ptr).to_bytes()`
* Change from `CString::from_slice` to `CString::new`
* If possible return a NulError when CString::new fails
* Otherwise, unwrap
* This can be changed (either way) if needed
* Switch from ContravariantLifetime to PhantomData
* Fixed some unused variable errors in tests
* Other minor changes
`EventPump` is an object-oriented approach to event loops.
The `EventPump` type allows us to enforce certain invariants about
event pumping at compile-time, such as thread safety.
Event pumping may only occur on the main thread, and as such,
`EventPump` implements `!Send`.
Iterators have been added as a more Rust-y way to implement
event looping.
Some thread-safe functions, such as event pushing and peeking,
are still defined at the module-level and not inside of a type.
This is to allow other threads to call these functions freely without
the need to borrow any values.
* In addition to adding `EventPump`, a `running` variable was added
in the graphical examples to cleanly exit out of the main loop
(without using `break 'main`).
* `EventPump`::wait_iter()` is used for the game controller and
joystick examples to avoid hogging the CPU.
* `use sdl2::event::Event;` is put inside the iterator to encourage
scoping `use`s to where they're needed instead of at the
module-level.