These seem to work only for single layer tilemaps. I'd like to work with a multi-layer tilemap though.
What i mean is, every wold tile is in fact an array of tiles so i can stack multiple tiles on the same spot.
sw::TileMap is designed to be used for static, single layered tile-maps. It could still be used, however, using a few of them drawn directly on top of each other for the layers and choosing the correct tile depending on the frame of animation but this becomes so manual that it's likely to be better to build a more bespoke tile map.
Vertex array would still be your port of call, though.
For the layers, you can either use a number of vertex arrays, where the higher ones only include the tiles that have things on that layer, or a single vertex array and just resize it (or don't send all vertices to the draw method) to include all tiles. All primitives are drawn in order so the ones at the end of the array would be drawn on top of the ones at the beginning.
Just to be clear,
sf::VertexArrays aren't technically arrays; internally, they use
std::vectors therefore they can be dynamically
resized.
1. Draw visible tiles to offscreen renderTexture
2. Draw PCs, NPCs and objects to offscreen renderTexture
3. Apply effects / mask / lighting / what not to offscreen renderTexture
4. Draw the GUI to offscreen renderTexture
5. draw the renderTexture to the renderWindow
If you are drawing the render texture directly to the window, there is no point in using the render texture because all of the drawing would be the same as the window and then it's just copied onto the window, so it would be the same as doing points 1-4 directly to the window.
Sorry; no bacon!The render texture can come in useful if you need to modify the entire contents together - as one - before (or during using a shader/blendmode) drawing it to the window, such as scaling, moving, rotating.
What about an array(vector) of sf::RenderTextures? Each render texture would represent a different layer.
This could be useful if each layer needs to be processed individually but that's unlikely and probably rare.