SDL_SetWindowIcon(3)
π SDL_SetWindowIcon(3) π
okay so bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, this one is literally called SDL_SetWindowIcon and it does exactly one iconic thing: it sets the icon for a window. that's it. that's the whole vibe. π
β¨ NAME β¨
SDL_SetWindowIcon β set the icon for a window. π
π SYNOPSIS π
#include <SDL3/SDL_video.h>
bool SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
like. two arguments. one bool. we love a minimal signature. π
π¦ DESCRIPTION π¦
okay so here's the tea, and it's actually kind of genius. π
if you pass this function a surface that has alternate representations added to it using SDL_AddSurfaceAlternateImage(), then that surface gets interpreted as the content for 100% display scale, and the alternate representations get used for high DPI situations. so it's giving "one icon, many resolutions, we're prepared for every screen." β¨
for example β and this is the example, bestie, I'm not making it up β if the original surface is 32x32, then on a 2x macOS display or 200% display scale on Windows, a 64x64 version of the image will be used, if available. π
and if a matching version of the image isn't available? then the closest larger size image will be downscaled to the appropriate size and be used instead, if available. and if that's not available either? then the closest smaller image will be upscaled and be used instead. it's a whole fallback chain and honestly it ate. π₯
π FUNCTION PARAMETERS π
windowβ the window you're changing, bestie. the one getting the glow-up. πiconβ anSDL_Surfacestructure containing the icon for the window. yes, a wholeSDL_Surface. bring your own pixels. πΌοΈ
β RETURN VALUE β
returns true on success or false on failure. π
and if it fails, call SDL_GetError() for more information, because the error message is the group chat that will tell you what actually went wrong. no cap. π
π§ THREAD SAFETY π§
β οΈ this function should only be called on the main thread. periodt. do not try it anywhere else, the main character energy stays on the main thread. π
πΈ AVAILABILITY πΈ
this function is available since SDL 3.2.0. so if you're on something older, it's simply not giving. π
π SEE ALSO π
SDL_AddSurfaceAlternateImage(3)β the bestie that makes the high DPI magic possible. go read it. π«Ά
Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_SetWindowIcon(3)
and that's the whole page babes, mwah π this was SDL 3.4.18 brought to you by the Simple Directmedia Layer girlies, signing off, stay slaying your window icons β¨π πΈ
π¦ 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