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

Author Topic: Which method is faster?  (Read 1758 times)

0 Members and 1 Guest are viewing this topic.

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
Which method is faster?
« on: May 12, 2018, 05:20:21 pm »
If I will draw a sequence of 1000 rectangles, which would be better (and faster): to have 1 RectangleShape and make 1000 draws, or have an array of 1000 RectangleShapes and make 1 draw?

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Which method is faster?
« Reply #1 on: May 12, 2018, 08:32:22 pm »
probably faster having 1000 rectangle shapes and make one draw, but how would you do it?
for every shape, you would need to call
render_window.draw(rectangle_shape[n]);
so, it's 1000 draws anyway.

on the other hand, you could use a single VertexArray instead of 1000 RectangleShapes, an then you could really draw everything in one call.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Which method is faster?
« Reply #2 on: May 13, 2018, 02:30:06 am »
You are right, thanks.