diff --git a/changelog.md b/changelog.md index 12808ac830..6a70e84c53 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,8 @@ when upgrading from a version of rust-sdl2 to another. ### Next +[PR #1451](https://github.com/Rust-SDL2/rust-sdl2/pull/1451) Add `gamma_ramp_arrays` and `calculate_gamma_ramp`. + [PR #1416](https://github.com/Rust-SDL2/rust-sdl2/pull/1416) Apply clippy fixes, fix deprecations and other code quality improvements. [PR #1408](https://github.com/Rust-SDL2/rust-sdl2/pull/1408) Allow comparing `Version`s, add constant with the version the bindings were compiled with. diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index c758a61425..66402052ca 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -1984,6 +1984,20 @@ impl Window { } } + #[doc(alias = "SDL_GetWindowGammaRamp")] + pub fn gamma_ramp_arrays(&self) -> Result<[[u16; 256]; 3], String> { + let mut ret = mem::MaybeUninit::<[[u16; 256]; 3]>::uninit(); + let ptr = ret.as_mut_ptr().cast::(); + let result = unsafe { + sys::SDL_GetWindowGammaRamp(self.context.raw, ptr, ptr.add(256), ptr.add(512)) + }; + if result == 0 { + Ok(unsafe { ret.assume_init() }) + } else { + Err(get_error()) + } + } + /// Set the transparency of the window. The given value will be clamped internally between /// `0.0` (fully transparent), and `1.0` (fully opaque). /// @@ -2138,3 +2152,12 @@ pub fn drivers() -> DriverIterator { index: 0, } } + +#[doc(alias = "SDL_CalculateGammaRamp")] +pub fn calculate_gamma_ramp(gamma: f32) -> [u16; 256] { + unsafe { + let mut ret = mem::MaybeUninit::<[u16; 256]>::uninit(); + sys::SDL_CalculateGammaRamp(gamma as c_float, ret.as_mut_ptr().cast::()); + ret.assume_init() + } +}