SDL_GetDisplayContentScale(3)
π SDL_GetDisplayContentScale π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_GetDisplayContentScale(3) β the lil function that tells you how big the user wants their UI to be on a given display. let's get into it π«Ά
β¨ NAME β¨
SDL_GetDisplayContentScale β get the content scale of a display. that's it, that's the vibe π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_video.h>
float SDL_GetDisplayContentScale(SDL_DisplayID displayID);
π¦ DESCRIPTION π¦
so, the content scale is the expected scale for content based on the DPI settings of the display. think of it like: a 4K display might have a 2.0 (200%) display scale, which means the user literally expects UI elements to be twice as big on this display, to aid in readability. it's giving "my eyes said no thank you to tiny text" ππ
β οΈ important glow-up tip: after window creation, use SDL_GetWindowDisplayScale() to query the content scale factor for individual windows instead of querying the display for a window and calling this function. because the per-window content scale factor may differ from the base value of the display it is on β particularly on high-DPI and/or multi-monitor desktop configurations. no cap, this one matters π₯
π FUNCTION PARAMETERS π
displayIDβ the instance ID of the display to query. like, which screen are we talking about bestie π
β RETURN VALUE β
Returns the content scale of the display, or 0.0f on failure. if it fails, call SDL_GetError() for more information β she will tell you what went wrong, fr fr π
π§ THREAD SAFETY π§
This function should only be called on the main thread. do not be out here summoning it from a side thread, it's not that kind of party π
π AVAILABILITY π
This function is available since SDL 3.2.0. periodt β¨
π SEE ALSO π
and that's the whole page, bestie π tysm for reading β this one came straight from the Simple Directmedia Layer girlies, sitting pretty in SDL 3.4.18. go forth and scale your content responsibly ππ¦π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms