145 Commits

Author SHA1 Message Date
Antoni Spaanderman
ecd03de215 Render geometry binding (#1472)
* make `pixels::Color` have a stable representation (`repr(C)`)

this allows for faster code and is also needed for SDL_RenderGeometry

* add binding for SDL_RenderGeometryRaw

* add example of advanced use of `Canvas::render_geometry`

* update unsafe trait docs to include a needed guarantee

and refer to one doc comment instead of duplicating similar ones

* rework almost everything

- the macro was very hard to get sound, auto deref has to be prevented somehow
- the unsafe traits could not be implemented for types defined in other crates

the unsafety must be kept simple, users now only need to provide the
right offsets, which core::mem::offset_of does

update example

* add convenience impls for &Vec<_> to VertexIndices

* update example to use 2 ways of using render_geometry_raw, and use render_geometry

* mention alignment in safety comments in render_geometry example

* fix and improve docs

* update changelog
2025-03-31 09:20:58 +02:00
Antoni Spaanderman
d9ab3e0db0 fix clippy warnings and other improvements to code quality 2024-06-29 20:05:15 +02:00
Caspar Krieger
fd4844bdbd Make wgpu example compile and run again 2024-06-26 09:56:42 +08:00
Cobrand
c916cb4566 fmt 2024-06-13 15:52:12 +02:00
Noahnoah55
fd63cab008 Upgrade to raw-window-handle 0.6, imperfectly 2024-04-10 22:27:30 -04:00
Louis Johnson
c3d67f5dcd upgraded wgpu version to 0.15 for example and updated example code to match version 2023-04-16 14:36:45 +10:00
Nuckal777
2db28e02f5 Fix AppKitWindowHandle missing NSView 2022-12-18 22:52:45 +01:00
Nuckal777
31e830ede9 Update raw-window-handle to 0.5.0 2022-12-16 23:58:14 +01:00
Joe Clay
047eb79787 Make the fmt check pass 2022-05-30 23:52:43 +01:00
Joe Clay
5598b69336 Fix XInput support in the game-controller example (fixes #1230) 2022-05-30 19:49:16 +01:00
Cobrand
541f49af58 cargo fmt 2022-05-05 16:43:40 +02:00
Kaphula
28834018c1 Update wgpu to 0.12 and fix raw-window-handle-with-wgpu example program. 2022-05-03 04:01:24 +03:00
Ben Noordhuis
08d5e6ed85 fix formatting 2022-04-20 22:05:55 +02:00
Sorenon
f647d16e2a Implement controller touchpad events 2022-03-10 00:26:45 +00:00
rhysd
5d8ba4ac12 Return Result from AudioQueue::queue instead of bool 2021-12-30 11:46:13 +09:00
Cobrand
6a31d312ab Merge pull request #1131 from Yamakaky/sensor-api
Add sensor API implementation
2021-10-10 20:05:42 +02:00
Mikaël Fourrier
38e8261988 wgpu 0.10 + strip dependencies 2021-09-15 22:48:53 +02:00
Mikaël Fourrier
67fe292f19 First try at sensor API implementation 2021-08-21 13:55:56 +02:00
Cobrand
f6adc8daff Fix bindgen, update sdl_bindings.rs 2021-07-24 17:38:23 +02:00
Cobrand
593b5151ab fix audio-queue-squarewave example 2021-02-15 11:40:13 +01:00
Guillaume Gomez
7fd7ee4447 run cargo fmt 2020-12-08 20:30:47 +01:00
Cameron Mann
e1028ed682 Update raw-window-handle-with-wgpu example to use wgpu 0.5
* Remove WindowWrapper since wgpu now uses raw-window-handle correctly
  on OSX which also lets us remove the objc dependency
* Add futures dependency to handle parts of the wgpu API that are now
  asynchronous
* Flip y coords in vertex shader to keep triangle oriented the same way
  since wgpu flipped their y-axis
* Fix various other errors resulting from breaking API changes in wgpu
2020-05-26 23:14:52 -06:00
Jakub Stasiak
9dde795e3f Provide memory buffer -> mixer Chunk conversion methods
This basically provides an API to access Mix_QuickLoad_WAV and
Mix_QuickLoad_RAW with one caveat – thie API takes ownership of the
buffers, while Mix_QuickLoad_* functions don't. Since Rust-SDL2 wraps
Mix_Chunks in its own structure with its own buffer ownership flag it's
easy to work around that and deallocate the buffer when Chunk is
dropped.

There are few design considerations here:

* Taking ownership of the buffer. I couldn't come up with a way to
  get a Chunk based on a buffer while still keeping the code safe and
  making sure that as long as Chunk is alive the buffer is also alive
  *and* not making the change be terribly involved and disruptive
* What's the best way to take an ownership of a buffer passed as a
  parameter? I came up with Box<[T]> as it seems universal enough,
  but I expect a more idiomatic Rust way may exist.

I modified the mixer demo to show how the API is used, a beep is
generated when no sound file is passed to the example.
2020-02-07 00:39:07 +01:00
Logan McGrath
b48a21d394 Never trust IDE auto-imports 2020-01-31 13:15:56 -08:00
Logan McGrath
92b4309564 adding an example 2020-01-30 12:15:59 -08:00
Cobrand
e865c8f464 Add events example, add missing events 2019-11-06 11:50:42 +00:00
Jakub Stasiak
4e37c1b789 Fix clicking and volume control in the audio-wav example 2019-10-23 02:53:28 +02:00
Cobrand
1d5f701d0f Enable no_std for sdl2-sys 2019-03-23 15:04:53 +00:00
Sunjay Varma
37cf5f76ac Replaced all calls to unwrap() in examples with either the ? operator or expect 2019-01-13 22:49:05 +01:00
Drew Pirrone-Brusse
8f27656a6a Update to bitflags 1.* from 0.7 2018-12-21 13:37:06 +01:00
Niels Wießner
5b7d1c108f Modify joystick example to include set_rumble 2018-12-10 23:22:59 +01:00
Niels Wießner
59ad1c094b Modify game-controller example to include set_rumble 2018-12-10 23:07:57 +01:00
Cobrand
cfced74f15 Fix audio whitenoise example 2018-10-15 17:31:20 +00:00
Jon Emil Jahren
a27c3c62a5 Convert SDL_mixer bindings into autogenerated bindings
Progresses on #647
2018-04-02 11:19:22 +02:00
Jessica Stokes
809fee03a1 Use power_level in the joystick example 2018-03-31 18:58:33 +02:00
Constantin Nickel
8184caf3fd sdl2::mixer::open_audio must be called before other functions 2018-02-15 18:14:45 -08:00
Martin Lindhe
80fbbab198 avoid dependency of gfx 2017-12-26 19:39:10 +01:00
Martin Lindhe
87db9987c8 add an example using a custom mouse cursor
example: cargo run --example cursor --features="image gfx" assets/cursor.png
2017-12-21 13:34:40 +01:00
vrinek
58989c973d Remove unused macro definition 2017-11-08 18:31:32 -08:00
Luke Jones
600ddbf593 Update animation.rs and change art to CC0 licensed art 2017-10-31 08:18:06 +01:00
Cobrand
bb0d05ff6c Merge pull request 695, add bindgen support 2017-10-27 07:15:29 +00:00
Jessica Stokes
5809b73e53 Update haptic example to use joystick index 2017-10-09 21:05:01 -07:00
Dario Ostuni
b32d1fca5d Update bundled SDL2 headers to version 2.0.6 2017-09-23 21:27:38 +02:00
Dario Ostuni
e3d70f63c2 Sync with master 2017-09-23 21:06:08 +02:00
Joshua Erney
0f44d43595 Fix floating-point literal used in pattern in example (#705) 2017-09-21 18:33:06 +02:00
Dario Ostuni
7eacb548ad Sync with master 2017-09-05 16:23:43 +02:00
Cobrand
ceb547d92f Update examples in Cargo.toml to avoid failing tests with unsafe_textures feature 2017-09-04 22:33:15 -07:00
Dario Ostuni
b00e88962c Introducing bindgen 2017-08-30 23:16:51 +02:00
shybyte
0e2ac14266 Fixed clippy warnings in audio-capture-and-replay example. 2017-07-08 22:09:27 -07:00
shybyte
059cf96ee5 Do not specify AudioSpecDesired.freq in audio-capture-and-replay example in order to avoid problems with sound cards, which might not be able to record with 44100 hz. 2017-07-08 22:09:27 -07:00