SFML community forums
Help => General => Topic started by: Chuckleluck on November 13, 2011, 02:57:22 am
-
Is there a way to change the window icon from the default icon to a custom .ico image on a window created by the sf::RenderWindow class, like you can with a Win32-made window?
-
I suppose you mean the .exe file icon. not the icon thats displayed in the title bar. (in case you mean that, there is a sfml function for that).
you could either use reshacker or something like that.
or you could include one icon as a "resource" with the id IDI_ICON1 or something like that. (then you could also set it as the title-bar icon)
edit: i meant
http://www.sfml-dev.org/documentation/1.6/classsf_1_1Window.php#a36fa09e52af66878b8b826457b8f1dfa
-
Is there a way to change the window icon from the default icon to a custom .ico image on a window created by the sf::RenderWindow class, like you can with a Win32-made window?
You have to create a .rc file and then import it in your project.
This is the code:
IDR_APP_ICON ICON "(.ico filename)"
GLUT_ICON ICON "(.ico filename)"
-
What kind of variable will the last argument accept? It says it's a Uint8*, but I don't know what that is. :oops:
Could someone give me an example of how to use SetIcon?
-
Depending on your IDE, you could try right clicking on Uint8 to find the definition. This is a very common typedef for an unsigned char (Unsigned integer of 8 bits).
The SetIcon function wants a Uint8 pointer which is called pixels(this is a big clue). Hey! 8 bits per channel per pixel - maybe this is related. You need to provide the window with an array of pixels, which, conveniently sf::Image provides. http://sfml-dev.org/documentation/1.6/classsf_1_1Image.php#ad1594ab4251d6fc833a48dd242918631
-
So I need to include an Image object? Could you please provide an example?
-
window.SetIcon(image.GetWidth(), image.GetHeight(), image.GetPixelsPtr());
That should work.
-
Yes! It works now. Thank you to Felheart, Naufr4g0, Walker and luiscubal for your help :D