Skip to content

Commit

Permalink
Added 32-bit array pixelformats
Browse files Browse the repository at this point in the history
  • Loading branch information
Rua authored and Cobrand committed Dec 21, 2018
1 parent b6fa720 commit 9a03451
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/sdl2/pixels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@ pub enum PixelFormatEnum {
YVYU = sys::SDL_PIXELFORMAT_YVYU as i32
}

// Endianness-agnostic aliases for 32-bit formats
#[cfg(target_endian = "big")]
impl PixelFormatEnum {
pub const RGBA32: PixelFormatEnum = PixelFormatEnum::RGBA8888;
pub const ARGB32: PixelFormatEnum = PixelFormatEnum::ARGB8888;
pub const BGRA32: PixelFormatEnum = PixelFormatEnum::BGRA8888;
pub const ABGR32: PixelFormatEnum = PixelFormatEnum::ABGR8888;
}

#[cfg(target_endian = "little")]
impl PixelFormatEnum {
pub const RGBA32: PixelFormatEnum = PixelFormatEnum::ABGR8888;
pub const ARGB32: PixelFormatEnum = PixelFormatEnum::BGRA8888;
pub const BGRA32: PixelFormatEnum = PixelFormatEnum::ARGB8888;
pub const ABGR32: PixelFormatEnum = PixelFormatEnum::RGBA8888;
}

impl PixelFormatEnum {
pub fn from_masks(masks: PixelMasks) -> PixelFormatEnum {
unsafe {
Expand Down

0 comments on commit 9a03451

Please sign in to comment.