Load the image into a sf::Image, then pass its size (width & height) as the first two parameters and for the third one: image.getPixelsPtr().
#include <SFML/Graphics.hpp>
sf::Image myicon;
int main()
{
myicon.loadFromFile("snake.ico");
sf::RenderWindow mywindow(sf::VideoMode(800,600,32),"icon");
sf::Event ev;
mywindow.setIcon(32,32,myicon.getPixelsPtr());
while(mywindow.isOpen())
{
while(mywindow.pollEvent(ev))
{
if(ev.type == sf::Event::Closed)
mywindow.close();
}
mywindow.clear(sf::Color(0,200,0));
mywindow.display();
}
}
I get an error in the console window that says:
Failed to load image "snake.ico". Reason : Image not of any known type, or corrupt.
Also.... how can i pass the width and height?
myicon.width or height doesn't exist.
There is a tutorial on the SFML Wiki:
Tutorial: Create and Use SetIcon
That tutorial is from 1.6, and in 2.0 theres no .width or .height