2781 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
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
renski
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 Cieslewicz
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
Cobrand
34867707c9 Merge pull request #1450 from jagprog5/clipping_rect_ambiguous
add ClippingRect
2025-02-19 11:48:16 +01:00
John Giorshev
e7f01849a1 fix fmt 2025-02-18 13:43:53 -05:00
John Giorshev
76a697e1a3 drop let binding 2025-02-18 13:38:38 -05:00
Cobrand
07ae517179 Merge pull request #1441 from DJawna/AdditionalLogPrios
Add additional Logging level functions to the logging module
2025-02-18 19:36:27 +01:00
Cobrand
7236c51447 Merge pull request #1445 from orcharddu/update-msvc-docs
Update Windows (MSVC) instructions
2025-02-18 19:31:48 +01:00
Cobrand
f082146f42 Merge pull request #1452 from antonilol/fix-clone-drop
remove unnecessary clone
2025-02-18 19:27:14 +01:00
John Giorshev
880632d6f4 improve - settings is now backwards compatible. querying is not 2025-02-07 22:54:05 -05:00
John Giorshev
acc5d3bc37 changelog entry 2025-01-27 09:35:51 -05:00
John Giorshev
3b8743977e cargo fmt 2025-01-27 09:31:50 -05:00
John Giorshev
25b61eb43e amend previous commit (add eq) 2025-01-26 16:50:24 -05:00
Antoni Spaanderman
ef5bfe8f55 remove unnecessary clone 2025-01-05 13:45:45 +01:00
John Giorshev
13676261eb add derive 2025-01-02 14:40:35 -05:00
John Giorshev
6a218432ec add ClippingRect type 2025-01-02 14:24:08 -05:00
Orchard Du
b75c78d8e9 Update MSVC instructions to fix LNK1181 error 2024-12-10 08:23:53 +08:00
Daniel Jawna
383eb6eb0d Introduced Logging priority based loggin functions
which call the generic logging function
2024-10-28 18:19:55 +01:00
Daniel Jawna
eb781c2902 consolidate the different logging wrapper functions into one
function which accepts priority enum as parameter
2024-10-28 16:44:48 +01:00
Daniel Jawna
0a4edf8e59 Replace the log level specific wrapper functions with inline lambdas
cargo fmt the code
2024-10-26 21:29:45 +02:00
Daniel Jawna
1b76b49486 Add additional Logging level functions to the logging module 2024-10-22 12:27:34 +02:00
Antoni Spaanderman
42a547b1a5 Fix copy-paste mistake in WindowBuilder::build
closes #1432
2024-09-18 18:17:00 +02:00
Cobrand
400e033411 Merge pull request #1426 from Nemris/fix-doc-typo
Fix documentation typo
2024-08-12 14:40:15 +02:00
Nemris
fa1f7cf7e8 Fix typo 2024-08-12 08:32:59 +02:00
Cobrand
dba66e80b1 Merge pull request #1419 from shivkr6/patch-1
fix docs
2024-07-02 10:48:05 +02:00
Cobrand
fea253cdf4 Merge pull request #1417 from TheRealDust/fixed-lints
Fixed Dead Code Warning
2024-07-02 10:47:56 +02:00
Shivang K Raghuvanshi
63d39fad82 fix docs
Fixed a typo in the readme.
2024-07-02 09:32:50 +05:30
TheRealDust
ad94eeb136 Fixed Dead Code Warning
Disabled dead code warning.
2024-07-02 11:22:28 +10:00
Cobrand
315c9e22d5 Merge pull request #1416 from antonilol/clippy-fixes
fix clippy warnings and other improvements to code quality
2024-07-01 12:29:53 +02:00
Antoni Spaanderman
1dabf0e838 update changelog and fix fmt 2024-06-29 20:15:12 +02:00
Antoni Spaanderman
d9ab3e0db0 fix clippy warnings and other improvements to code quality 2024-06-29 20:05:15 +02:00
Cobrand
a57f9adf50 Merge pull request #1412 from caspark/fix-wgpu-example
Make wgpu example compile and run again
2024-06-26 15:08:12 +02:00
Caspar Krieger
fd4844bdbd Make wgpu example compile and run again 2024-06-26 09:56:42 +08:00