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

Author Topic: sf::View performance  (Read 1914 times)

0 Members and 1 Guest are viewing this topic.

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
sf::View performance
« on: April 29, 2013, 08:09:12 pm »
Let's say I have a tile map stored as a big vertex array (which is for example 10 000 x 10 000 pixels). My window is 800x600. Then I use a sf::View to scroll the map and I render it using window.draw(map). The question is: will only the visible part be drawn (only 800x600 px, resulting in amazing performance) or the whole vertex array will be drawn (resulting in very bad performance)?

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::View performance
« Reply #1 on: April 29, 2013, 08:56:46 pm »
The whole vertex array will be drawn, resulting in amazing performance ;D

If you really need to optimize the amount of vertices sent to the graphics card, you can divide your world in chunks (the optimal size is up to you to decide), and manage them in a 2D partitioning structure like a quad-tree.
Laurent Gomila - SFML developer

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: sf::View performance
« Reply #2 on: April 29, 2013, 09:01:58 pm »
Okay thanks. What will be faster: rendering one big 10 000 x 10 000px vertex array or rendering just 25x19 32px visible tiles? Then every tile is separate sf::Sprite, all are using the same texture.

Of course I could benchmark it, but my map code is quite complex and I'm considering switching to vertex array but I'm not sure.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::View performance
« Reply #3 on: April 29, 2013, 09:07:47 pm »
It's really hard to say.
Laurent Gomila - SFML developer

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Re: sf::View performance
« Reply #4 on: April 29, 2013, 09:11:05 pm »
Okay, so I will need to do benchmarks. Is there a way to render only a fragment of vertex array (like it's possible with texture)? That would be the best.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::View performance
« Reply #5 on: April 29, 2013, 10:40:32 pm »
Quote
Is there a way to render only a fragment of vertex array (like it's possible with texture)?
No, that's why I said you would have to split your world into smaller separate chunks if you want to optimize out invisible parts.
Laurent Gomila - SFML developer