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