SFML community forums

Help => Graphics => Topic started by: TheCommunistDuck on March 26, 2010, 09:51:38 pm

Title: Drawing just an sf::Image?
Post by: TheCommunistDuck on March 26, 2010, 09:51:38 pm
Hi.

sf::Image doesn't actually derive from sf::Drawable, so how would you draw one to the screen?
I ask because my current project requires me to edit pixels in an sf::Image and then draw it to the screen. I've tried plugging it into an sf::Sprite and then GetImage(), but that returns a const sf::Image which I can't modify. Any ideas anyone, for either way?

Thanks. :D
Title: Drawing just an sf::Image?
Post by: nulloid on March 26, 2010, 10:01:14 pm
What if you just have your sf::Image in your memory, modify it asyouwant, and whenever you want it to draw, just make an sf::Sprite from it, and draw that to the screen?
Title: Drawing just an sf::Image?
Post by: TheCommunistDuck on March 26, 2010, 10:14:43 pm
Wouldn't that consume a lot of memory, doing it 60 times a second though?
Title: Drawing just an sf::Image?
Post by: Laurent on March 26, 2010, 11:18:52 pm
Quote
Wouldn't that consume a lot of memory, doing it 60 times a second though?

No ;)
But you don't have to setup a new sprite every frame, you can just create it once. You don't even need to call SetImage after modifying the image.
Title: Drawing just an sf::Image?
Post by: nulloid on March 26, 2010, 11:24:55 pm
Quote from: "Laurent"

But you don't have to setup a new sprite every frame, you can just create it once. You don't even need to call SetImage after modifying the image.


Wow... There is always something to learn :D
Title: Drawing just an sf::Image?
Post by: Spodi on April 06, 2010, 04:52:26 am
That is what I am currently doing. The way my rendering system was already set up before using SFML kinda required it. Same goes for drawing text. I just create a single Sprite and String2D and set it up before each draw. Very simple and low overhead. :)