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