SDL_GetWindowSize(3)

πŸ’– SDL_GetWindowSize(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're gonna talk about SDL_GetWindowSize β€” she's the one who tells you how big your window's client area is. no cap. πŸͺŸβœ¨


✨ NAME ✨

SDL_GetWindowSize β€” get the size of a window's client area.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_video.h>

bool SDL_GetWindowSize(SDL_Window *window, int *w, int *h);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie: the window pixel size may lowkey differ from its window coordinate size if the window is sitting on a high pixel density display. like, it's giving "same window, two different numbers" 😭.

if you want the real client area size in pixels, use SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize(). those are the ones who actually know. πŸ’…


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window you wanna query the width and height from. πŸ‘‘
  • w β€” a pointer that gets filled in with the width of the window. she may be NULL, and that's fine, we don't judge. πŸ™ˆ
  • h β€” a pointer that gets filled in with the height of the window. also may be NULL. iconic behaviour honestly. πŸ’œ

⭐ RETURN VALUE ⭐

returns true on success or false on failure. if it fails, hit up SDL_GetError() for more info β€” she'll tell you what went wrong. πŸ”₯


🧚 THREAD SAFETY 🧚

this function should only be called on the main thread. do not be out here calling her from a side thread, that's not the vibe. πŸ’€

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on something older, sorry bestie, she's not there yet. 😭


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! 🫢 this was brought to you by Simple Directmedia Layer, version SDL 3.4.18 β€” go get those window dimensions, you absolute main character. slay. πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from