SDL_SetWindowSize(3)

πŸ’– SDL_SetWindowSize β€” the SDL3 FUNCTIONS glow-up ✨

okay bestie, so you wanna resize a window's client area? say less. this is SDL_SetWindowSize(3) from the SDL3 FUNCTIONS manual and she is lowkey iconic πŸ’…


🌸 NAME 🌸

SDL_SetWindowSize β€” request that the size of a window's client area be set. it's giving "pls resize" energy, and I'll explain why "request" is doing so much heavy lifting here 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_video.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

first things first, bestie: if the window is in a fullscreen or maximized state, this request has no effect. like, none. she's booked and busy, don't even try it πŸ’€

wanna change the exclusive fullscreen mode of a window instead? that's a whole different girl, use SDL_SetWindowFullscreenMode().

now, on some windowing systems this request is asynchronous, which means the new window size may not have been applied immediately upon the return of this function. the way that it just... returns before the vibe is settled 😭 if you need an immediate change, call SDL_SyncWindow() to block until the changes have taken effect. no cap, that's the move.

when the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be emitted with the new window dimensions. but β€” and this is the part nobody tells you β€” the new dimensions may not match the exact size you requested, because some windowing systems can restrict the window size in certain scenarios (e.g. constraining the size of the content area to remain within the usable desktop bounds). additionally, since this is just a request, it can be denied by the windowing system. the audacity, honestly πŸ™ˆ

so yeah: you ask, the windowing system decides. main character energy but make it polite ✨

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window to change. the one getting the makeover πŸ’…
  • w β€” the width of the window, must be > 0. zero and negatives are not invited to this party, periodt.
  • h β€” the height of the window, must be > 0. same rule, bestie, no exceptions 🌈

πŸ’œ RETURN VALUE πŸ’œ

returns true on success or false on failure. and if it's a flop? call SDL_GetError() for more information. she'll tell you everything πŸ“


🧚 THREAD SAFETY 🧚

this function should only be called on the main thread. do not try to be sneaky on a worker thread, I'm literally begging you 😭 main thread only, iykyk.


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if your SDL is older than that, no resize for you, sorry babe πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! mwah πŸ’– this came to you straight from Simple Directmedia Layer, running SDL 3.4.18 β€” go resize something and slay πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from