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

Author Topic: FPS issue  (Read 1701 times)

0 Members and 1 Guest are viewing this topic.

FortunateSonn

  • Newbie
  • *
  • Posts: 3
    • View Profile
FPS issue
« on: July 13, 2017, 09:15:53 pm »
I'm creating a game with a grid system, so currently I'm drawing 6000 squares that cover the screen. Doing this
drops the game down to 12 fps. I know what you're thinking, I'm an idiot for wanting to draw 6000 squares and keep a high frame rate. I just want to know if there is a way so I can draw the squares in intervals? So as to keep seeing the squares on screen but slow down how often they are drawn? Not sure if this is possible or even a good idea. Wondering if I should just scale down rectangles instead.

Sidenote: Would using a view with a zoomed in view showing maybe only 50 squares increase the framerate?

korczurekk

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Email
Re: FPS issue
« Reply #1 on: July 14, 2017, 01:57:47 am »
How do you draw those rectangles? sf::Sprite is too slow due to large amount of drawcalls, if you use it, you need to switch to sf::VertexArray, that way you should get decent FPS despite rendering multiple rectangles.

FortunateSonn

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: FPS issue
« Reply #2 on: July 14, 2017, 02:55:36 am »
How do you draw those rectangles? sf::Sprite is too slow due to large amount of drawcalls, if you use it, you need to switch to sf::VertexArray, that way you should get decent FPS despite rendering multiple rectangles.
I'm just drawing regular rectangleshapes. Just wondering, how is a vertex array a quicker option? I'm not familiar with it.


Sent from my iPhone using Tapatalk

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: FPS issue
« Reply #3 on: July 14, 2017, 10:41:41 am »
The main bottleneck is often the number of calls to draw(). 6000 of them is going to be slow. A vertex array allows you to group geometry together into a single array of data, for which you only need to call draw() once. You can read about them here. Bear in mind, however, vertex arrays can have their own problems such as this.

FortunateSonn

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: FPS issue
« Reply #4 on: July 14, 2017, 02:41:30 pm »
Ok, I understand much better now. Thanks for helping a noob out guys!