I swear, that this FRex on github is not me.. you believe me, right?
No
?
Well, ok.. Let's digest this post... and this code is not optimal, it's a basic example. If you really need a lot of performance(you don't, probably..) there is a shader based approach in projects subforum.
Is the clipping necessary? Isn't it actually costing performance?
Yes it is, in theory you're limited by ram, so you could have a map of 1024x1024 tiles, each being 32x32.
With default constants:
enum {tilesize=32,chunksize=32};//change values of these to match your needs and improve performance
that's sizeof(sf::Vertex)*4 mb + vectors cost. But if you drew everything with 60 fps, you'd be drawing and texturing 60 milions of
quads per second = 240 milion vertices per second -That's a bit too much..
edit: Another question: Why are you using a 2 dimensional Array of sf::VertexArray's instead of one std::vector<sf::Vertex>?
And do what? Draw extreme amount of quads from across the map? I did do, in my editable tile map(not on wiki) single vector of arrays and just offset in the array and get right amount of vertices passed to draw, it was slower than this one, but it was easily editable.
Because from my experience it's more efficient to draw a big Vertexarray (containing Quads) once instead of drawing a lot of quads. And if I understand the source code correct every quad inside the clipping range is drawn individually
They are not drawn individually. arrays are drawn, each of them has chunksize*chunksize quads in them, or less if it's bottom or right edge of map. Matching constants makes big difference. I'm fairly sure for 32x32 tiles, 32x32 chunks are better than 64x64 or 16x16. I did little bit of tests, but only a litte.
And look at the sizes, 32 pixels per * 32 tiles per chunk = 1024 pixels per chunk side. That is quite a lot. In some bizzare scenario, like 2048x2048 view and most unfortunate position, you will draw 9 times. Usually less, and with normal views(ie. my 1360 wide, 700 something high screen) you will draw much much less(usuall 4 on fullscreen for me, 6 in unfortunate positions).
Oh, and the example uses the arrays from sf, I use vectors of vertices instead of SFML arrays so they can be optimized with reserve, usually they allocate up to 30% more memory than they actually use.
Oh2: there is a thread about my map example in wiki subforum