2786 Commits
Author SHA1 Message Date
biroder 244ae85833 Bump SDL to fix build with CMake 4.x 2025-07-02 14:22:55 +03:00
Antoni Spaanderman 89f3ebef3c fix windows build by adding a library (#1488) 2025-06-23 12:08:27 +02:00
Kevin Nakamura 1eafd6f516 Explicitly set -std=gnu99 (via CMAKE_C_STANDARD) for linux targets when using the bundled feature. (#1480) 2025-06-22 21:25:29 -04:00
JktuJQ 7cae29bcce Documentation for sdl2::video (#1487)
* Documentation for `sdl2::video`

Provided documentation for most of the `sdl2::video` functions.

Mostly did that to resolve some uncertanties in functions purpose (`grab`/`keyboard_grab`/`mouse_grab`, `minimize`).

Looked at `SDL_SetWindowData`/`SDL_GetWindowData` ToDo: think that those functions should be removed.

* Remove trailing `///` after comments

* Checked 'ToDo's
2025-06-22 14:34:39 +02:00
Luke Jones ededb3009e fix: Change type signature of try_get_string in locale.rs (#1486)
The type of the pointer from libc may change depending on the target
architecture. Pass the libc type instead.
2025-06-22 12:41:43 +02:00
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 f0cdbb32b5 remove impl ToColor for isize (#1473)
* remove `impl ToColor for isize`

- there is an impl for `u32` already, that impl is now the only one so
  rustc easily figures out the number type, that does not have to be
  explicitly annotated anymore.
- `isize` is not always wide enough to represent all colors. writing
  0xff0000ffisize compiles on 64 bit systems but not on 32 or 16 bit
  systems. (deny-by-default warning, if `allow`ed it will panic at
  runtime)

* update changelog
2025-03-27 23:11:54 +01:00
Antoni Spaanderman 829071af17 suppress warnings: unknown edition and unexpected cfg (#1471) 2025-03-26 09:07:07 +01:00
Antoni Spaanderman f9231b465f replace unsound use of transmute with u32::from_be_bytes (#1470) 2025-03-26 09:01:27 +01:00
Antoni Spaanderman 6534b96f3b use TTF_GlyphIsProvided32 and TTF_GlyphMetrics32 instead of the 16 bit ones (#1414)
* use TTF_GlyphIsProvided32 and TTF_GlyphMetrics32 instead of the 16 bit ones

* update changelog
2025-03-21 14:22:14 +01:00
Antoni Spaanderman 5be34ce7cd Fix ub and shrink unsafe blocks (#1435)
* fix transmuting to invalid value

* fix public access to raw pointer

* add `repr(transparent)` to safely pointer-cast

between `FRect` and `sys::SDL_FRect`, and `FPoint` and`sys::SDL_FPoint`.

* add null pointer check before calling `CStr::from_ptr`

also shrink unsafe blocks

* return pointer with mutable provenance from `FRect::raw_mut`

before this commit writing to the pointer returned by `FRect::raw_mut`
was undefined behavior.

* fix use after free and unwind through FFI boundary in timer.rs

* update changelog
2025-03-20 14:06:44 +01:00
renskiandAntoni Spaanderman fca5c3782e Added system locale support (#1427)
* add system locale hint, query & event

* update changelog

* cleanup

* fix multiple hint formatting, changelog

* locale formatting optimization, additional formatting tests

* Update changelog.md

Co-authored-by: Antoni Spaanderman <49868160+antonilol@users.noreply.github.com>

* remove redundant `Result` return type from `format_locale_hint`

---------

Co-authored-by: Antoni Spaanderman <49868160+antonilol@users.noreply.github.com>
2025-03-19 16:59:34 +01:00
Alexander Cieslewiczandciciplusplus dc6f555c31 Replace slashes in NDK path when building for android on windows (#1462)
On windows the ANDROID_NDK_HOME path can use backslashes. This causes
issues in cmake. Replaces \ with / on windows compilation hosts.

Co-authored-by: ciciplusplus <ciciplusplus@gmail.com>
2025-03-19 09:12:14 +01:00
Alexander Cieslewicz bccd248c63 Update sensor types and Return correct SensorData Enum (#1461)
* Return proper SensorData for Gyroscope

* Update SensorTypes to match SDL bindings

* Update changelog
2025-03-19 09:11:46 +01:00
Martin Sundhaug 01099a5733 Fix minor readme formatting issue (#1467) 2025-03-18 16:25:02 +01:00
Antoni Spaanderman c242701c1e Prevent users from creating Sdl2TtfContext out of nothing and use SDL's reference counting init/quit (#1437)
* prevent users from creating `Sdl2TtfContext` out of nothing

and various other changes, including:
- allow multiple `ttf::init` calls, the same way it works with TTF_Init
- return last sdl error instead of I/O error (like stale pr #1348, fixes #1347 and closes #1348)
- implement `Clone` for `Sdl2TtfContext`, SDL C code will do the reference counting
- make `ttf::font::internal_*` `pub(super)`
- make `ttf::font::Font::raw` safe (obtaining a raw pointer is safe, using it is unsafe)

* remove `InitError` because only one variant was used

* update changelog
2025-03-08 18:26:36 +01:00
Antoni Spaanderman 863399d8f2 fix vcpkg build ubuntu (#1466) 2025-03-06 15:07:53 -05:00
Henrique Jorge Barateli 173b414700 Added binding for Mix_OpenAudioDevice (#1464) 2025-03-06 11:02:14 -05:00
John Giorshev e2d5a14627 make ttf raw pub (#1458)
* make ttf raw pub

* rm unsafe
2025-03-05 14:56:59 +01:00
Antoni Spaanderman 0e6fbe320a add gamma_ramp_arrays and calculate_gamma_ramp (#1451) 2025-03-05 08:27:41 -05:00
John Giorshev 9f97c166d6 add scale_mode to unsafe_textures (#1465) 2025-03-05 08:25:25 -05:00
John Giorshev d6de6b2015 fix init (#1459) 2025-03-04 12:46:39 -05:00
John Giorshev eff9730727 Add texture scale mode (#1444) 2025-03-04 12:18:32 -05:00
Antoni Spaanderman d16a7c48c7 store gfx::framerate::FPSmanager directly in FPSManager instead of on the heap (#1415)
* store gfx::framerate::FPSmanager directly in FPSManager instead of on the heap

* update changelog
2025-03-03 15:51:53 -05:00
John Giorshev 825047eb3a Merge pull request #1434 from antonilol/fix-1432
Fix copy-paste mistake in WindowBuilder::build
2025-03-02 18:29:03 -05:00