Function SDL_GetClosestFullscreenDisplayMode

pub unsafe extern "C" fn SDL_GetClosestFullscreenDisplayMode(
    displayID: u32,
    w: i32,
    h: i32,
    refresh_rate: f32,
    include_high_density_modes: bool,
    closest: *mut SDL_DisplayMode,
) -> bool
Available on crate feature dep_sdl3 only.
Expand description

Get the closest match to the requested display mode.

The available display modes are scanned and closest is filled in with the closest mode matching the requested mode and returned. The mode format and refresh rate default to the desktop mode if they are set to 0. The modes are scanned with size being first priority, format being second priority, and finally checking the refresh rate. If all the available modes are too small, then false is returned.

§Parameters

  • displayID: the instance ID of the display to query.
  • w: the width in pixels of the desired display mode.
  • h: the height in pixels of the desired display mode.
  • refresh_rate: the refresh rate of the desired display mode, or 0.0f for the desktop refresh rate.
  • include_high_density_modes: boolean to include high density modes in the search.
  • closest: a pointer filled in with the closest display mode equal to or larger than the desired mode.

§Return value

Returns true on success or false on failure; call SDL_GetError() for more information.

§Thread safety

This function should only be called on the main thread.

§Availability

This function is available since SDL 3.2.0.

§See also