Search code examples
c++sfmlframe-rate

SFML main loop for best fps


I need to create a game for university project in a short time, with sfml and c+. My question is that how fast the sfml2.0?

I mean if I recreate all the background, sprites at each step in the main loop, would it cause a low fps rate? So, can I just make a bitmap with all the elements on, and draw it?

Or I must have repaint only the changes, pixel by pixel and then refresh the screen.

The reason I am asking, cause later in the past, when I choose the first version (truthfully redraw everything pixel by pixel) with sdl, it was very slow, and the second option described above seems to require more work, and I only have like 3 day to do it.

I hope you understand the topic that confused me, and you can give me a nice advise how to do it.


Solution

  • In each frame you have to :

    1) clear the screen

    2) draw your sprites

    3) display the screen

    Obviously, you dont have to recreate all sprites at each step.