Hey there
From what I gathered in the various posts I read here, there is some black magic available to draw tile maps, and that is the VertexArray.
I understand this is a kind of Graal for many 2D games, so I'll try to understand it a little better.
Some people said I could divide the world in big chunks, with a vertexArray for each chunk, and use these chunks for culling.
So how exactly does it work ? Here are my thoughts.
- Each chunk represents a static part of the map. So it's set once at first, and never ever edited again.
- The visible chunks are picked and drawn. Since the visible part of the map can move (or we wouldn't need culling in the first place), it means we have to translate the chunks to their correct position. But the documentation says VertexArrays are not transformable.
Does this mean we can't translate the whole array ?
If we can't, then will we need to translate each vertex individually ? But then we lose the "set once, don't touch again" property of these chunks...
Now, I'll propose another solution. Since I didn't see it mentioned in the threads I read, I'll assume that's because I missed something, and I'll be glad if you can show it to me.
We'll start from a VertexArray-less situation, with the usual per-tile culling, and where we draw each tile individually.
Now, let's just replace the single-sprite drawing call with one that adds a quad to the vertex array, with the position it would have been drawn to.
In the end, the vertex array just acts as a gatherer for all the draw calls, and bath them all in the end.
Was I too unclear ?
If not, would it even work ?
If it would, would it be much slower than the other method ? In the end, we only have one draw() call, and tile-precise culling.