Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Window Icon Using SDL_SetWindowIcon()

Tags:

c++

linux

sdl-2

I'm currently developing a game with SDL2 in C++ and I want to set my game's icon for the task bar and for the Alt-Tab switcher. I am trying to achieve this by using SDL_SetWindowIcon():

SDL_Surface* icon = IMG_Load("icon.png");
SDL_SetWindowIcon(sdlWindow, icon);

Even if my window is correctly initialized and the surface is loaded, the icon does not appear in the task bar or in the Alt-Tab switcher. I am on Ubuntu 16.04 LTS.

Does anyone know what I'm doing wrong?

like image 328
mathlizee Avatar asked Sep 13 '25 10:09

mathlizee


1 Answers

I'm not going to claim that I understand how this function works, but I can share with you how I got it to work. Even though I could use a 600x600 (pixels) image in the desktop.my_app file, and using that launcher would work fine, SDL2 would NOT load a 600x600 image. I tried 128x128 too, and that didn't work.

Changing the image size to 64x64 miraculously fixed it. Storage issue? I don't know why SDL2 can handle huge SDL_Surface s in other parts of the app but not the window icon....

like image 107
Matt B Avatar answered Sep 16 '25 03:09

Matt B