Apologies, I assumed Linux was probably not targetted.
So you're saying that setting an icon with an array containing RGBA data did not change the icon at runtime?
Indeed, it has no effect. It doesn't cause any ill effects either, essentially using Window::setIcon() causes my program to run no differently than if I left it out completely.
The first way I tried using it was by exporting it as a C structure from Gimp. I did make sure for it to export as RGBA by telling it to also save the alpha channel. Naturally I'll exclude the majority of this source as the actual pixel data exported is massive. The first small section is what is important anyway.
static const struct {
unsigned int width; // = 64
unsigned int height; // = 64
unsigned int bytes_per_pixel; // = 4 I'd say this makes it fairly certain it's RGBA
unsigned char pixel_data[width * height * bytes_per_pixel + 1]; // u8 array
} feudal_forge_icon = { 64, 64, 4,
// afterwards pixel_data gets defined by a giant exported array also generated by Gimp
};
After including the header file,
// Note there are exclusions
Engine::Engine()
{
m_window.create(sf::VideoMode(800, 600, 32), "Feudal Forge", sf::Style::Default, initContextSettings());
m_window.setIcon( feudal_forge_icon.width, feudal_forge_icon.height, feudal_forge_icon.pixel_data);
}
After seeing this didn't work ( and note I have gotten this to work before on Windows) I decided to try loading the icon from memory.
// Note there are exclusions
bool Engine::init(...)
{
m_icon.loadFromFile("icon.png");
// The window has already been created in the constructor
m_window.setIcon(m_icon.getSize().x, m_icon.getSize().y, m_icon.getPixelsPtr());
}
Using this method led to the exact same thing. The icon didn't change, but there wasn't any crash, error message, etc.
Really to replicate my situation you can throw out 99% of my program.
If you'd like to try to compile my first example, you'll need the header file with the embedded image. I'll go ahead and link that. After you have it, it should work with this ( to save you time )
#include<SFML/Graphics.hpp>
#include<FeudalForgeIcon.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480, 32), "Icon Test");
window.setIcon( feudal_forge_icon.width, feudal_forge_icon.height, feudal_forge_icon.pixel_data );
while(window.isOpen())
{
sf::Event evt;
while(window.pollEvent(evt))
{
if(evt.type == sf::Event::Closed) { window.close(); }
}
window.clear();
window.display();
}
}
For the second method I tried, I'm sure you can make some minor change to the above code.
I'd include the image directly but it's too large to just throw in the thread, so please look at the attachment.
You can see my icon at the bottom there.
As for the other method, it looks exactly the same.
Other Info:
Ubuntu 15.04 - Unity
Intel i5 - 2.4 ghz
Intel HD Integrated graphics Sandybridge Mobile
(I'm using the latest graphics drivers I can get from the Intel Graphics Installer)
RAM 6gb