Commit Graph
27 Commits
Author SHA1 Message Date
Cobrand f1a76882d6 Fix clippy errors: first pass 2017-05-03 09:15:54 +02:00
AndresandCobrand 19c5d12602 Split the Renderer
Created a Canvas + TextureCreator
2017-05-02 07:30:18 +02:00
Cobrand bccbdc39c4 Fix examples' warnings 2016-12-02 21:21:47 +01:00
Machtan 877bb42cbb Make all examples work and all tests pass after the error/rect changes 2016-02-11 21:15:31 +01:00
Machtan f103ac04fa Fix the usages of Rect::new_unwrap in the examples 2016-02-09 21:26:06 +01:00
Sven Nilsen dbe51ab2d6 Update dependencies
- Bumped to 0.10.0
2015-11-09 17:08:14 +01:00
Ryszard c794be4e2a Changes in example loops
- 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)
2015-10-14 00:52:11 +03:00
Dan Spencer b8de00fe52 Update examples 2015-07-27 02:06:25 -06:00
Dan Spencer f8f02c7a2c Unalias Rect and Point from sys, make immutable, check Rect invariants 2015-06-18 02:52:11 -06:00
Tony Aldridge a556fb73d3 Merge pull request #424 from nukep/keyboard
Keyboard state iterator, move Scancode and Keycode enums
2015-06-16 11:29:30 +01:00
Dan Spencer d600fe7ed6 Move drawer methods into Renderer 2015-06-14 05:50:17 -06:00
Dan Spencer 2af5dcfac4 Move Keycode and Scancode into the keyboard module, adjust spelling
* 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.
2015-06-14 02:04:34 -06:00
Dan Spencer ef23bab267 Replace Unknown variants in Keycode and Scancode with Option::None 2015-06-14 00:55:11 -06:00
Dan Spencer acb12f9b05 Update examples 2015-05-21 18:44:32 -06:00
Dan Spencer e6d6c34689 SDL2 initialization uses the builder pattern
* InitFlag has been removed completely
* Sdl::init_subsystem has been moved into the builder
2015-05-17 14:28:23 -06:00
Dan Spencer 4bd42eda8e Renderer uses the builder pattern
* RenderDriverIndex and RendererFlags have been removed completely.
2015-05-17 14:28:14 -06:00
Dan Spencer 42ca5587d4 Window uses the builder pattern
* 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.
2015-05-17 14:28:00 -06:00
Dan Spencer 7d27c53c54 Window safety: Ensure thread, event-pump safety
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.
2015-04-11 06:23:56 -06:00
Dan Spencer beaa1744fe Remove Texture lifetime, add "is renderer alive" Rc to Texture
* Remove `owned` field from Texture.
* Remove RefMut from Renderer, make Renderer::drawer() take &mut self.
2015-04-11 06:23:51 -06:00
Nicholas Mazzuca ce9faaf17f Merge remote-tracking branch 'upstream/master' into fixed
Conflicts:
	examples/game_controller.rs
	examples/joystick.rs
	src/sdl2/sdl.rs
2015-02-23 01:41:49 -08:00
Nicholas Mazzuca 9ab8cfaf18 Fix compile and warnings, change to 0.0.28/0.0.27
* 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
2015-02-23 01:09:17 -08:00
Dan Spencer 9975515950 Add EventPump and update examples to use new EventPump
`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.
2015-02-22 14:04:08 -07:00
Dan Spencer 2a5ce5f1bf Add Sdl type 2015-02-21 21:42:58 -07:00
Tony Aldridge b33b30273a Merge branch 'master' of git://github.com/nukep/rust-sdl2 into nukep-master
Conflicts:
	src/sdl2/render.rs
2015-01-30 13:14:49 +00:00
Dan Spencer 8094d99c30 Fix renderer-texture example to use immutable texture reference 2015-01-30 02:27:03 -07:00