SDL_GetWindowPixelDensity(3)

πŸ’– SDL_GetWindowPixelDensity πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_GetWindowPixelDensity β€” the girl who tells you how dense your pixels are. no cap.


✨ NAME ✨

SDL_GetWindowPixelDensity β€” get the pixel density of a window. that's it, that's the whole job, and she does it flawlessly πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_video.h>

float SDL_GetWindowPixelDensity(SDL_Window *window);

✨ DESCRIPTION ✨

so like, this is a ratio of pixel size to window size. think of it as: how many actual pixels are you getting per unit of window, bestie? πŸ”

for example β€” and I love this example β€” if the window is 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it would have a pixel density of 2.0. double the pixels, double the slay. it's giving retina. it's giving crisp. periodt. βœ¨πŸ¦‹


✨ FUNCTION PARAMETERS ✨

  • window β€” the window to query. yes, the one you want the density tea about πŸ«–

✨ RETURN VALUE ✨

returns the pixel density, or 0.0f on failure 😭 β€” and if it fails, call SDL_GetError() for more information, because she will tell you what went wrong.


✨ THREAD SAFETY ✨

⚠️ this function should only be called on the main thread. no side-quests, no other threads, no exceptions. main thread only, bestie. 🚫🧡

✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. so if you're on anything older… yeah, she's not there yet. upgrade time πŸ’€


✨ SEE ALSO ✨


and that's the whole page, bestie!! πŸŒˆπŸ’œ this lil' cutie came to you from Simple Directmedia Layer, running the SDL 3.4.18 era β€” so go forth, query your density, and stay crispy βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from