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

Author Topic: Efficiency...  (Read 3804 times)

0 Members and 2 Guests are viewing this topic.

jjmoore

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Efficiency...
« on: May 05, 2021, 03:22:15 pm »
Apologies in advance,
If this has been asked before... please point me in the right direction...

So with regards to the statement... "performance depends in large part on the number of calls to the draw function ..."

What is the most effective and efficient way to call groups of primitives...?

A draw() for all your points (one vertex array) followed by a draw() for all your triangles (its own vertex array) and then followed by lines (again another vertex array), and so on?

Assuming you had a large but reasonable number of all drawable primitives that you wanted to update and draw each frame... In other words, the worst case scenario... Is this the best approach?

Or, can something be done with a virtual base class and a collection via polymorphism? Without any offset for different vertex requirements..?.. So, you only call draw() once for all the primitives collected and required? I guess you could translate everything into single points, a vertex, in an array and have another matching array for the number of vertices... ?

Thanks in advance for any advice... Finally, may I ask, if you know of anyone to ever use SFML to plot realtime and or static data based charts... Financial and scientific?

All the best, Jonathan


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Efficiency...
« Reply #1 on: May 05, 2021, 04:04:57 pm »
You essentially need a vertex array per primitive type and per texture (if any).

Note that performance should always be profiled and not assumed. So what's best for your scenario we can't really say.
The statement also doesn't mean you can only ever have one draw call, but it means that if you do thousands of draw calls, you'll most likely start to notice worse performance compared to a single or two or three draws calls with vertex arrays.

As for the primitive situation, I personally, would probably bet on using triangles for everything, because sooner than later, you realize that you want your points to be bigger or your lines to be thicker and you end up using triangles after all.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jjmoore

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Efficiency...
« Reply #2 on: May 06, 2021, 12:44:04 am »
Thank you.

 

anything