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

Author Topic: Drawing array of vertices - efficiency  (Read 1446 times)

0 Members and 1 Guest are viewing this topic.

Akasata

  • Newbie
  • *
  • Posts: 6
    • View Profile
Drawing array of vertices - efficiency
« on: July 01, 2018, 02:39:33 am »
Hi. I'm curious about efficiency related to drawing process. Let's say that we have a vertex array full of rectangles and we want to draw it at certain position. There are two ways to do it:

First: We can fill vertex array with properly positioned vertices and then draw it.

Second: We can fill vertex array with vertices relative to point (0, 0) and then we can apply transform to render states. (Transform may be applied at the very beginning, not in every draw call.)

Is it any difference in efficiency in this situation? What is better solution?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing array of vertices - efficiency
« Reply #1 on: July 01, 2018, 09:34:50 am »
If the whole geometry moves the same, then use a transform, it's almost free. And most important, you can save the CPU -> GPU transfer by using a sf::VertexBuffer, which can be a huge improvement as the vertex data can stay on the GPU instead of being sent every frame.
Laurent Gomila - SFML developer

Akasata

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Drawing array of vertices - efficiency
« Reply #2 on: July 01, 2018, 02:39:38 pm »
In my case all vertices have same movement. So I'll use transform method. But I am interested in using sf::VertexBuffer. Could you give some examples of using it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing array of vertices - efficiency
« Reply #3 on: July 01, 2018, 07:53:12 pm »
This is almost the same as sf::VertexArray. The documentation explains the differences.
Laurent Gomila - SFML developer

Akasata

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Drawing array of vertices - efficiency
« Reply #4 on: July 01, 2018, 10:59:19 pm »
Thanks. :D