SFML community forums
Help => General => Topic started by: Yaxlat on March 21, 2015, 10:51:30 pm
-
I am creating a platformer game using SFML, and my "Level Size" is a lot larger than my window size. So I am using sf::View to move around the view while I move.
What I do every frame is:
- I draw everything onto the window
- Set the view to be part of the window
- Run window.display()
- Run window.clear()
What I want to do now, however, is to draw each element onto an image (.png) file. A couple details:
- This image should be the same size as my "Level Size"
- I don't want it zoomed in anyway - it should not be affected by my current window or view
- Finally there are transparent parts of the image, because I have not drawn them onto my canvas. I do not want these black in my image, but rather transparent
How can I achieve this? Ideally I would like to run a function like this: exportPNG(string filename, level).
Thanks a lot!
-
You can draw everything onto a transparent sf::RenderTexture, then get the sf::Texture of your render texture, then copyToImage() and saveToFile().
But if it is "a lot" larger than your window, you may be limited by the maximum texture size.
-
You can draw everything onto a transparent sf::RenderTexture, then get the sf::Texture of your render texture, then copyToImage() and saveToFile().
But if it is "a lot" larger than your window, you may be limited by the maximum texture size.
Ok, thanks a lot! I'll see what I can do, I haven't messed around with that yet. When I say a lot, I'm talking about 5000px maximum, so I think I'll be fine.
-
then get the sf::Texture of your render texture
How can I do this?
-
I'm pretty sure you'll find how if you take a look at the documentation of sf::RenderTexture.