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

Author Topic: Vertex Array using individual textures?  (Read 1225 times)

0 Members and 1 Guest are viewing this topic.

zakkor

  • Newbie
  • *
  • Posts: 27
    • View Profile
Vertex Array using individual textures?
« on: June 02, 2014, 07:47:42 pm »
I implemented a small top-down tilebased game using individual textures and sprites to draw the map, and now I'm experiencing poor performance due to the large amount of draw calls (I'm guessing that's what it is.)
Looking at the vertex array tutorial (http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php) I can see that it uses a tileset. If I were to implement a tileset, I think i would need to rewrite a lot of code, so what I'm asking is: is it possible to just add(convert) the sprites that have textures and positions already assigned to them to the vertex array and then just draw that?
I know this is not the most optimized way, but I'm thinking the sprite creation and handling is negligible performance-wise (correct me if I'm wrong). Would this grant me a noticeable performance boost?
How do I do it?

If you need me to post some code, don't hesitate to ask, please!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Vertex Array using individual textures?
« Reply #1 on: June 02, 2014, 07:56:13 pm »
and now I'm experiencing poor performance due to the large amount of draw calls (I'm guessing that's what it is.)
Don't guess. Measure.

is it possible to just add(convert) the sprites that have textures and positions already assigned to them to the vertex array and then just draw that?
I know this is not the most optimized way, but I'm thinking the sprite creation and handling is negligible performance-wise (correct me if I'm wrong). Would this grant me a noticeable performance boost?
Vertex arrays are not magically faster, they're faster because a lot of objects can be drawn at once. Therefore, you still need the logic to find out which sprites need the same texture. You can try to create vertex arrays in addition, but why not directly?

If this adaption comes with a huge effort, that's a sign that rendering is not modular or encapsulated enough. Ideally, not the whole game uses sprites directly, but rather a few central classes related to rendering.

How do I do it?
This is explained in the tutorial and API documentation of sf::VertexArray.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything