SDL_SetWindowShape(3)
β¨ SDL_SetWindowShape(3) β¨
okay bestie, gather round π this is a page from the SDL3 FUNCTIONS collection, and it's all about SDL_SetWindowShape β the glow-up your window deserves.
πΈ NAME πΈ
SDL_SetWindowShape β set the shape of a transparent window. yes, shape. like, silhouette. main character energy for your window frame π
π SYNOPSIS π
#include <SDL3/SDL_video.h>
bool SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape);
π¦ DESCRIPTION π¦
okay so here's the tea fr fr: this function sets the alpha channel of a transparent window, and any fully transparent areas are also transparent to mouse clicks. so it's not just a look, it's literally a vibe check for your input events too. obsessed.
ngl though, if you're using something besides the SDL render API, then you are responsible for drawing the alpha channel of the window to match the shape alpha channel to get consistent cross-platform results. no cap, that part is on you π«Ά
the shape is copied inside this function, so you can free it afterwards. icon behaviour honestly. but if your shape surface changes, you should call SDL_SetWindowShape() again to update the window.
β οΈ heads up: this is an expensive operation, so it should be done sparingly. it's giving "treat it like a limited-edition drop", not "call it in a loop" π
and the window must have been created with the SDL_WINDOW_TRANSPARENT flag. no flag, no shape, periodt.
π FUNCTION PARAMETERS π
windowβ the window. yeah, that one. the window you're shaping πshapeβ the surface representing the shape of the window, orNULLto remove any current shape. soNULLis basically the "never mind, back to rectangle" button π
β RETURN VALUE β
returns true on success or false on failure. and if it fails? call SDL_GetError() for more information β she will tell you what went wrong, iykyk.
π§ THREAD SAFETY π§
this function should only be called on the main thread. don't be messy about it, bestie π
π AVAILABILITY π
this function is available since SDL 3.2.0. so if you're on anything older, it's simply not giving β¨
and that's the whole page, mwah π this was SDL_SetWindowShape(3) from Simple Directmedia Layer, version SDL 3.4.18 β go forth and shape your windows, you absolute legend ππ¦π
π¦ 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