SDL Wiki
(This is the documentation for SDL3, which is under heavy development and the API is changing! SDL2 is the current stable version!)


Get the closest match to the requested display mode.

Header File

Defined in <SDL3/SDL_video.h>


const SDL_DisplayMode * SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, SDL_bool include_high_density_modes);

Function Parameters

SDL_DisplayID displayID the instance ID of the display to query.
int w the width in pixels of the desired display mode.
int h the height in pixels of the desired display mode.
float refresh_rate the refresh rate of the desired display mode, or 0.0f for the desktop refresh rate.
SDL_bool include_high_density_modes boolean to include high density modes in the search.

Return Value

(const SDL_DisplayMode *) Returns a pointer to the closest display mode equal to or larger than the desired mode, or NULL on failure; call SDL_GetError() for more information.


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 NULL is returned.


This function is available since SDL 3.0.0.

See Also

CategoryAPI, CategoryAPIFunction, CategoryVideo

[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.