SDL_GetDisplayProperties(3)

πŸ’– SDL_GetDisplayProperties πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_GetDisplayProperties(3) β€” she's the one who tells you literally everything the system knows about a display. no cap. πŸ–₯️✨


πŸŽ€ NAME πŸŽ€

SDL_GetDisplayProperties</purgle> β€” get the properties associated with a display. that's it, that's the vibe. πŸ’…


🌸 SYNOPSIS 🌸

first, you gotta let her in:

#include <SDL3/SDL_video.h>

then you say hi like this:

SDL_PropertiesID SDL_GetDisplayProperties(SDL_DisplayID displayID);

yes ma'am, one arg, one property ID back. iconic behavior. 🫢


✨ DESCRIPTION ✨

so here's the tea: SDL hands you back a bunch of read-only properties. read-only, meaning look but don't touch, bestie, they're not yours to edit. πŸ™ˆ

here's the whole list, no gatekeeping:

  • SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN β€” true if the display has HDR headroom above the SDR white point. and like… this is for informational and diagnostic purposes only, because not every platform is gonna give you this info at the display level. so don't build your whole app on it, okay? it's giving "nice to know" not "load-bearing". πŸ”₯

and now, the platform-specific girlies πŸ‘‘

On KMS/DRM:

  • SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER β€” the "panel orientation" property for the display, measured in degrees of clockwise rotation. ⚠️ but heads up, this is provided only as a hint, and your application is responsible for any coordinate transformations needed to conform to the requested display orientation. so SDL is handing you the info and going "you got it from here babe", fr fr. 😭

On Wayland:

  • SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER β€” the wl_output associated with the display. πŸ¦‹

On Windows:

  • SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER β€” the monitor handle (HMONITOR) associated with the display. πŸͺŸ

πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • displayID β€” the instance ID of the display you wanna query. like, which screen, bestie. πŸ‘€

πŸ’œ RETURN VALUE πŸ’œ

returns a valid property ID on success, or 0 on failure. and if it flops? call SDL_GetError() for more information, because she will absolutely tell you what went wrong. πŸ’€


πŸ”’ THREAD SAFETY πŸ”’

this function should only be called on the main thread. do not try it anywhere else, i'm so serious, that's not the move. 🚫🧡


🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on something older, sorry bestie, no properties for you. πŸ’”


and that's the whole page, you ate it, you understood it, periodt. πŸŽ€

this lil gem lives in the Simple Directmedia Layer docs, straight outta SDL 3.4.18, and yeah, the page header and footer both say SDL_GetDisplayProperties(3) β€” consider yourself fully caught up. mwah. πŸ’–πŸ’…

πŸ“¦ where this page comes from