My problem that I need to draw tiles en masse, for a 1080p its around 8000 tiles ((1920/16) * (1080/16)). My approach thus far is generating an array of source and dest:
Code: Select all
core::array<position2d<s32>> destinationBatch;
core::array<rect<s32>> sourceBatch;
Code: Select all
destinationBatch.clear();
sourceBatch.clear();
int i = 0, j = 0;
for (int h = player.getCoordinatesX(); h < screenTileSize.Height + player.getCoordinatesX(); h++)
{
for (int w = player.getCoordinatesY(); w < screenTileSize.Width + player.getCoordinatesY(); w++)
{
int posH = tilemap[h][w] / 8;
int posW = tilemap[h][w] % 8;
destinationBatch.push_back(position2d<s32>(16 * i, 16 * j));
sourceBatch.push_back(rect<s32>(posW * 16, posH * 16, (posW + 1) * 16, (posH + 1) * 16));
i++;
}
j++;
i = 0;
}
//somewhere later in the loop
driver->draw2DImageBatch(tileAtlas, destinationBatch, sourceBatch);
The only solution I can see is using a 32x32 or 64x64 tiles, but I don't really want to do that. Any ideas that can be useful?
EDIT: forgot to add that im using opengl driver