sdlxGetWindowAspectRatio function video
Get the aspect ratio of a window's client area.
\param window the window to query the width and height from. \param min_aspect a pointer filled in with the minimum aspect ratio of the window, may be NULL. \param max_aspect a pointer filled in with the maximum aspect ratio of the window, may be NULL. \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.2.0.
\sa SDL_SetWindowAspectRatio
extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect)
See also:
Implementation
({double minAspect, double maxAspect})? sdlxGetWindowAspectRatio(
Pointer<SdlWindow> window,
) {
var minAspect = 0.0;
var maxAspect = 0.0;
final minAspectPointer = ffi.calloc<Float>();
final maxAspectPointer = ffi.calloc<Float>();
final result = sdlGetWindowAspectRatio(
window,
minAspectPointer,
maxAspectPointer,
);
if (result) {
minAspect = minAspectPointer.value;
maxAspect = maxAspectPointer.value;
}
minAspectPointer.callocFree();
maxAspectPointer.callocFree();
if (!result) {
return null;
}
return (minAspect: minAspect, maxAspect: maxAspect);
}