SDL_GetWindowDisplayScale(3)

πŸ’– SDL_GetWindowDisplayScale πŸ’–

okay bestie, welcome to the manual page for SDL_GetWindowDisplayScale, part of the SDL3 functions fam (that's SDL3 FUNCTIONS to the people who care about the formalities ✨). We're getting the content display scale relative to a window's pixel size, and honestly? it's giving main character energy.


✨ NAME ✨

SDL_GetWindowDisplayScale β€” get the content display scale relative to a window's pixel size πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_video.h>

float SDL_GetWindowDisplayScale(SDL_Window *window);

πŸ’… DESCRIPTION πŸ’…

So this value is literally a combo meal of two things: the window pixel density and the display content scale. And that combo is the expected scale for displaying content in this window. It's the vibe check for how big your stuff should be 🫢

Like, example time, because numbers make everything real. Say you've got a 3840x2160 window and its display scale is 2.0. The user expects the content to take twice as many pixels and still be the exact same physical size as if it were being displayed in a 1920x1080 window with a display scale of 1.0. No cap, that's the whole point β€” more pixels, same size on your actual eyeballs πŸ‘€

Conceptually, this value corresponds to the scale display setting, and it gets updated when:

  • that setting is changed πŸ”„
  • or the window moves to a display with a different scale setting πŸ–₯️ ➑️ πŸ–₯️

So it stays fresh. It's not stale, it's iconic.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window to query. That's it, that's the whole parameter, she's low maintenance πŸ’œ

⭐ RETURN VALUE ⭐

Returns the display scale, or 0.0f on failure 😭 β€” and if that happens, call SDL_GetError() for more information, because you deserve to know what went wrong bestie.


🧚 THREAD SAFETY 🧚

This function should only be called on the main thread. Not me catching you trying to call it from a worker thread πŸ™ˆ Don't. Main thread only. Periodt.

🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0 ✨


and that's the whole page, bestie!! πŸ’– brought to you by Simple Directmedia Layer, version SDL 3.4.18 β€” go forth and scale responsibly, mwah πŸŽ€πŸ’…

πŸ“¦ where this page comes from