diff --git a/include/SFML/Graphics/RenderWindow.hpp b/include/SFML/Graphics/RenderWindow.hpp index 3ca516a03..1466f2d07 100644 --- a/include/SFML/Graphics/RenderWindow.hpp +++ b/include/SFML/Graphics/RenderWindow.hpp @@ -35,6 +35,8 @@ namespace sf { +class Image; + //////////////////////////////////////////////////////////// /// \brief Window that can serve as a target for 2D drawing /// @@ -112,6 +114,18 @@ public: //////////////////////////////////////////////////////////// Vector2u getSize() const override; + //////////////////////////////////////////////////////////// + /// \brief Change the window's icon + /// + /// The OS default icon is used by default. + /// + /// \param icon Image to use as the icon. The image is copied, + /// so you need not keep the source alive after + /// calling this function. + /// + //////////////////////////////////////////////////////////// + void setIcon(const Image& icon); + using Window::setIcon; //////////////////////////////////////////////////////////// /// \brief Tell if the window will use sRGB encoding when drawing on it diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 045cd114c..ef7d457ce 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -26,6 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -65,6 +66,13 @@ Vector2u RenderWindow::getSize() const } +//////////////////////////////////////////////////////////// +void RenderWindow::setIcon(const Image& icon) +{ + setIcon(icon.getSize(), icon.getPixelsPtr()); +} + + //////////////////////////////////////////////////////////// bool RenderWindow::isSrgb() const {