bardes bardes - 2 months ago 7
C++ Question

How to manipulate images with SFML?

I'm working on a game and I need to draw a sequence of tiles into a

sf::Image
, but the only way I could draw something into a
sf::Image
(or
sf::Texture
) was by editing the pixels directly.

I'd like to know if there is any function like the
SDL_BlitSurface
or something like that in SFML. The only object I could draw things on was the
sf::RenderWindow
.

Am I doing something wrong or forgetting about something?

Answer

You can use sf::RenderTexture to call Draw functions with any drawable and take the result as a sf::Texture. You can then convert the sf::Texture to a sf::Image. Just take a look in documentation.