SDL_GetWindowPosition(3)

πŸ’– SDL_GetWindowPosition(3) β€” the SDL3 FUNCTIONS era πŸ’–

okay bestie, sit down, hydrate, and let me tell you about SDL_GetWindowPosition, aka the little guy who tells you where your window is at πŸͺŸβœ¨


🌸 NAME 🌸

SDL_GetWindowPosition β€” get the position of a window. that's it. that's the whole job. she's focused, she's employed, she ate πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_video.h>

bool SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);

yes queen, one include, one function call, three args. we love a low-effort slay πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

So like. This is the current position of the window, as last reported by the windowing system. Not a guess, not a vibe, not what you think it should be β€” what the windowing system actually told you most recently. no cap πŸ‘‘

And here's the little gift: if you genuinely do not need the value for one of the positions, you can pass NULL in the x or y parameter. don't care about the x? don't pass an x pointer. she's flexible like that, fr fr πŸ™ˆ


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window to query. the one we're asking about. the main character 🫢
  • x β€” a pointer that gets filled in with the x position of the window. may be NULL. if you pass NULL she's just not gonna tell you, and that's fine πŸ’œ
  • y β€” a pointer that gets filled in with the y position of the window. may be NULL. same deal, no judgement 🌸

⭐ RETURN VALUE ⭐

Returns true on success or false on failure β€” and if it's a fail, call SDL_GetError() for more information. like, she will NOT elaborate unprompted, you have to ask. classic πŸ’€

bestie if it returns false, do NOT just move on and pretend nothing happened. call SDL_GetError(). the lore is right there.

🧚 THREAD SAFETY 🧚

This function should only be called on the main thread. no side quests. no background threads thinking they can just roll up. main thread only, periodt 🚫🧡


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. if you're on anything older, she does not exist yet, and you're gonna have to cope 😭


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! this lil doc lives under Simple Directmedia Layer, SDL 3.4.18, and it's part of the SDL3 FUNCTIONS fam. go forth and query your windows responsibly πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from