Function SDL_DEFINE_PIXELFORMAT

pub const fn SDL_DEFINE_PIXELFORMAT(
    type: SDL_PixelType,
    order: i32,
    layout: SDL_PackedLayout,
    bits: u8,
    bytes: u8,
) -> SDL_PixelFormat
Available on crate feature dep_sdl3 only.
Expand description

A macro for defining custom non-FourCC pixel formats.

For example, defining SDL_PIXELFORMAT_RGBA8888 looks like this:

SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4)

§Parameters

  • type: the type of the new format, probably a SDL_PixelType value.
  • order: the order of the new format, probably a SDL_BitmapOrder, SDL_PackedOrder, or SDL_ArrayOrder value.
  • layout: the layout of the new format, probably an SDL_PackedLayout value or zero.
  • bits: the number of bits per pixel of the new format.
  • bytes: the number of bytes per pixel of the new format.

§Return value

Returns a format value in the style of SDL_PixelFormat.

§Thread safety

It is safe to call this macro from any thread.

§Availability

This macro is available since SDL 3.2.0.