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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms