SFML community forums
Help => Graphics => Topic started by: netrick on April 29, 2013, 08:09:12 pm
-
Let's say I have a tile map stored as a big vertex array (which is for example 10 000 x 10 000 pixels). My window is 800x600. Then I use a sf::View to scroll the map and I render it using window.draw(map). The question is: will only the visible part be drawn (only 800x600 px, resulting in amazing performance) or the whole vertex array will be drawn (resulting in very bad performance)?
Thanks.
-
The whole vertex array will be drawn, resulting in amazing performance ;D
If you really need to optimize the amount of vertices sent to the graphics card, you can divide your world in chunks (the optimal size is up to you to decide), and manage them in a 2D partitioning structure like a quad-tree.
-
Okay thanks. What will be faster: rendering one big 10 000 x 10 000px vertex array or rendering just 25x19 32px visible tiles? Then every tile is separate sf::Sprite, all are using the same texture.
Of course I could benchmark it, but my map code is quite complex and I'm considering switching to vertex array but I'm not sure.
-
It's really hard to say.
-
Okay, so I will need to do benchmarks. Is there a way to render only a fragment of vertex array (like it's possible with texture)? That would be the best.
-
Is there a way to render only a fragment of vertex array (like it's possible with texture)?
No, that's why I said you would have to split your world into smaller separate chunks if you want to optimize out invisible parts.