Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Handling very huge Tilemaps / images  (Read 1752 times)

0 Members and 2 Guests are viewing this topic.

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Handling very huge Tilemaps / images
« on: July 19, 2013, 05:16:25 pm »
Hello, i have created a map, well its 3200x8000 and as i thought it lags as fuck :/
The problem with the tilemap is that is created out of 30 tilesets and alone the .txt file which has the coordinates for the tilemaps is 1,7 Mb >_<
I just tried to insert the image with this:
                        sf::Texture testx;
         if (!testx.loadFromFile("brunnen3.png"))
         {
            std::cerr << "PlayerTexture could not load.";
         }
         sf::Sprite Testxy;
         Testxy.setTexture(testx);          
         window.draw(Testxy);
into the window but it lags as fuck, even if i make it on a 1700*3000 image or sth... anyone got a idea?

http://s1.directupload.net/images/130719/firesigx.png
« Last Edit: July 19, 2013, 06:01:33 pm by etixpp »

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Handling very huge Tilemaps / images
« Reply #1 on: July 19, 2013, 06:59:40 pm »
o.0 that is a lot of tiles... Can the player see all these tiles are once? or is this the 'zoomed' out version?

If the world is more zoomed in, you are going to want to only draw what the player can see.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Handling very huge Tilemaps / images
« Reply #2 on: July 19, 2013, 08:20:30 pm »
What's the point of tiles if you display one huge image?
Anyway, I'm not sure I understand your message. ^^

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Handling very huge Tilemaps / images
« Reply #3 on: July 19, 2013, 09:02:40 pm »
What I'm trying to say is you are drawing a lot of tiles. If your map size is 3200x8000 and each tile is 16x16 ( I'm guessing here), that would mean there's 100,000+ tiles that are getting drawn every single frame. I would expect it to run very slow at this point. You need to make less draw calls.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10991
    • View Profile
    • development blog
    • Email
AW: Handling very huge Tilemaps / images
« Reply #4 on: July 19, 2013, 09:19:31 pm »
If your problem is with the actual size of the texture, you could look into Thor's BigTexture and BigSprite class.
If the problem is with the slowness due to too many draw calls, try using vertex arrays.
If it's a mixture, you'll have to look into your own solution. Split the texture into multiples and use multiple vertex arrays (one for each texture), try to sort it as needed, only draw what's visible, etc. :)

Also a more descriptive explanation would be helpful. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/