SDL_GetPrimaryDisplay(3)

✨ SDL_GetPrimaryDisplay ✨

okay bestie, welcome to the SDL_GetPrimaryDisplay(3) page, straight outta the SDL3 FUNCTIONS manual. this one is short, sweet, and lowkey iconic: it tells you which display is the primary one. main character screen energy, no cap. πŸ‘‘


🌸 NAME 🌸

SDL_GetPrimaryDisplay β€” Return the primary display. that's it, that's the whole vibe. it hands you the display that the system considers the main one. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_video.h>

SDL_DisplayID SDL_GetPrimaryDisplay(void);

so you include <SDL3/SDL_video.h>, and you call SDL_GetPrimaryDisplay() with void β€” no args, she takes nothing, she gives you a SDL_DisplayID. periodt. πŸ’…


πŸ’– RETURN VALUE πŸ’–

on success, this returns the instance ID of the primary display. if it fails? it returns 0. and if you're sitting there like "bestie why 0??" β€” call SDL_GetError() for more information. that's the group chat receipt. 🧾

no cap: 0 means failure here, so don't treat it like a valid display ID. πŸ™ˆ

🧡 THREAD SAFETY 🧡

This function should only be called on the main thread. that's the rule, bestie. main thread only. don't be out here calling it from some random worker thread, it's not that kind of party. πŸ’€


🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on something older, it's giving "not invited." 😭


πŸ‘€ SEE ALSO πŸ‘€

  • SDL_GetDisplays(3) β€” the whole display list, if you want the full roster instead of just the primary. πŸ‘‘

and that's the page, bestie πŸ’– brought to you by Simple Directmedia Layer, SDL 3.4.18. slay, stay on the main thread, and go get that primary display. πŸŽ€βœ¨

πŸ“¦ where this page comes from