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 β¨
SDL_GetWindowDisplayScale(3)β her sister, also iconic, also worth a read π
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
- 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