SFML community forums

Help => Graphics => Topic started by: josephdetor on May 20, 2019, 01:07:47 pm

Title: TileMap Problem with 30,000,000 tiles
Post by: josephdetor on May 20, 2019, 01:07:47 pm
I am making a maze game.

I got a problem showing 30,000,000 tiles at the same time, it slow a lot the rendering process, it take 0.6 seconds for each frames.

My maze is composed of 2 sprite, one yellow and one blue. What decide the position of everything is a std::vector<std::vector<sf::Color>>. I draw everything by reference to the 2 existing sprite without copy of any kind. Even more, i only draw what can be seen by the view. But i have to test every sprite to know if they can be seen.

I would like to know if there are way to keep up 60 fps while been able to differentiate each tile programmatically.
Title: Re: TileMap Problem with 30,000,000 tiles
Post by: eXpl0it3r on May 20, 2019, 10:53:44 pm
What do you need 30M tiles for exactly?

Despite that number, your processor will have no problem traversing that set if data.
However when it comes to drawing, you're losing massive amount of time by making a draw call per tile. Instead use a vertex buffer (or vertex array).

As for reducing the need for iterating over everything. By using a quad tree or similar structures, you should be able to further reduce whatever checks you're doing.

Abd finally, don't forget that a 4K screen has only about 8-9M pixels. ;)