SFML community forums
Help => Graphics => Topic started by: parinho7 on April 01, 2013, 07:31:20 pm
-
Hi, I am new to sfml and I use the 2.0 rc version.
I have a problem displaying an image on the screen.
This is the piece of code I wrote:
sf::Texture texture;
if (!texture.loadFromFile("block.bmp"))
return false;
sprite.setTexture(texture);
sprite.setPosition(100, 25);
The problem is, I only get a white image instead of the normal colorized one. Why is that and how can I fix it?
Thanks in advance!
EDIT: Sorry, I just read this
It is important to note that the sf::Sprite instance doesn't copy the texture that it uses, it only keeps a reference to it. Thus, a sf::Texture must not be destroyed while it is used by a sf::Sprite
so I know what the problem is now!
-
Welcome to SFML and the forum! :)
To post code you should use the code=cpp tag instead of the quote tag.
As for your question, there's an answer in the FAQ (https://github.com/SFML/SFML/wiki/FAQ#wiki-graphics-white-rect), you might want to check it out. If you still don't get it, then you can come back and ask again. :)