SDL_WM_SetIcon(3)

πŸ’– SDL_WM_SetIcon(3) β€” the SDL API Reference, but make it cute πŸ’–

okay bestie, so you're in the SDL API Reference and this page is about SDL_WM_SetIcon, and it's literally the glow-up your window deserves. it's giving "my app has a face now" energy. ✨


🌸 NAME 🌸

SDL_WM_SetIcon β€” sets the icon for the display window. yes that's it. that's the whole job. iconic behavior, honestly. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include "SDL.h"

void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);

look at her. two params. no return. no drama. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so real talk: this function sets the icon for the display window. that's the little picture in your taskbar / title bar / wherever your window manager decided to put it. main character energy for your app. 🌈

heads up though β€” Win32 icons must be 32x32. no cap. if you roll up with some other size on Win32, that's not the vibe. πŸ“

also, this is the important one, so listen closely:

This function must be called before the first call to SDL_SetVideoMode.

like, before. not after. not during. before. it's giving "get there early or don't come at all." 🫢

so what do you actually pass in? it takes an icon surface, and a mask in MSB format. the mask is that little bitmask situation that tells the world which pixels are see-through. πŸ«₯

and here's the cute part β€” if mask is NULL, the entire icon surface will be used as the icon. no masking, no filter, just the whole thing, full send. πŸ“


✨ EXAMPLE ✨

SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), NULL);

look at that. one line. load a BMP, pass NULL for the mask, entire surface is the icon, done, slay. this is the "low effort, high reward" of the SDL world. πŸ’œ


πŸ‘€ SEE ALSO πŸ‘€

you're gonna want these too, they're basically the group chat:

  • SDL_SetVideoMode β€” the one you have to call after this one, remember?? 😭
  • SDL_WM_SetCaption β€” for the text up top, so your window has a name too πŸ’–

and that's the whole page, bestie!! this was written by the SDL crew, dated Tue 11 Sep 2001, 23:02, and it lives on as SDL_WM_SetIcon(3) in the manual forever. go forth and give your window a face. πŸŽ€πŸ¦‹βœ¨ no cap.

πŸ“¦ where this page comes from