sdlGetClosestFullscreenDisplayMode function
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.
\param displayID the instance ID of the display to query. \param w the width in pixels of the desired display mode. \param h the height in pixels of the desired display mode. \param refresh_rate the refresh rate of the desired display mode, or 0.0f for the desktop refresh rate. \param include_high_density_modes boolean to include high density modes in the search. \param closest a pointer filled in with the closest display mode equal to or larger than the desired mode. \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety This function should only be called on the main thread.
\since This function is available since SDL 3.1.3.
\sa SDL_GetDisplays \sa SDL_GetFullscreenDisplayModes
extern SDL_DECLSPEC bool SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *closest)
Implementation
bool sdlGetClosestFullscreenDisplayMode(
int displayId,
int w,
int h,
double refreshRate,
bool includeHighDensityModes,
Pointer<SdlDisplayMode> closest) {
final sdlGetClosestFullscreenDisplayModeLookupFunction =
libSdl3.lookupFunction<
Uint8 Function(Uint32 displayId, Int32 w, Int32 h, Float refreshRate,
Uint8 includeHighDensityModes, Pointer<SdlDisplayMode> closest),
int Function(
int displayId,
int w,
int h,
double refreshRate,
int includeHighDensityModes,
Pointer<SdlDisplayMode>
closest)>('SDL_GetClosestFullscreenDisplayMode');
return sdlGetClosestFullscreenDisplayModeLookupFunction(displayId, w, h,
refreshRate, includeHighDensityModes ? 1 : 0, closest) ==
1;
}