SDL_WINDOWPOS_CENTERED_DISPLAY(3)

πŸ’– NAME πŸ’–

SDL_WINDOWPOS_CENTERED_DISPLAY β€” the lil macro that tells SDL "bestie, center this window on that specific display, mwah" πŸŽ€

It lives in the SDL3 functions manual, and honestly? It's giving "one line of C, infinite power." ✨


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_video.h>

#define SDL_WINDOWPOS_CENTERED_DISPLAY(X)  (SDL_WINDOWPOS_CENTERED_MASK|(X))

That's it. That's the whole thing. No cap. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so. You want a window centered, right? And you want it centered on a specific display, not just whichever one SDL feels like picking? Say less. πŸ‘‘

SDL_WINDOWPOS_CENTERED does the same job, but it always uses the primary display instead of letting you specify one. So if you're on a multi-monitor setup (main character energy, honestly), and you want your window to pop up centered on monitor #2 instead of the boring default one, that's exactly when SDL_WINDOWPOS_CENTERED_DISPLAY comes in to slay. πŸ’–


πŸŽ€ MACRO PARAMETERS πŸŽ€

  • X β€” the SDL_DisplayID of the display you want to use. Literally just hand it the display's ID and it does the rest. 🫢

✨ AVAILABILITY ✨

This macro is available since SDL 3.2.0. So if you're on anything older, sorry babe, it's not happening. 😭


🌈 SEE ALSO 🌈

  • SDL_SetWindowPosition(3) β€” go read this one too, it's the whole reason you'd be passing these values around in the first place. iykyk. πŸ”₯

That's the whole vibe check, bestie β€” go center some windows on the exact display of your dreams. πŸ§šπŸ’œ

Signing off from the Simple Directmedia Layer crew, SDL 3.4.18 edition β€” catch you in the next SDL_WINDOWPOS...TERED_DISPLAY(3) page. πŸ’…β­

πŸ“¦ where this page comes from