0

Working on a 2D game with SDL2, for now on Window, but I'd like to dream and imagine that if I finish it, I could run it on other platforms that SDL2 games can target. A core part of which is GGPO based lockstep netplay. So, I want to fix my framerate (to 60fps).

On Windows, should I use VSync, but then somehow override/ignore it if the refresh rate of the monitor is not 60Hz? Or not use Vsync at all, and handle the fixed frame rate manually in all cases?

It seems in this case, various platform specific hoops need to be jumped through, as SDL_Delay (= Windows Sleep()) is nowhere near accurate enough. Seems I would need to dive out of platform independnce a bit to handle this?

Tom Davies
  • 181
  • 4
  • 1
    Have you considered leaving your framerate as is, but fixing your simulation timestep instead? This way you can get consistent evaluation of your game rules / netcode, without limiting rendering fidelity or platform complications. – DMGregory Mar 10 '21 at 12:33
  • My game is not frame rate dependent. The game engine can be updated with any time delta. However, lockstep online play is at the heart of my game, and this requires the same fixed framerate on both machines. If I choose to, I could choose to not fix the framerate in offline mode, but I won't (I just don't see any value in it) – Tom Davies Mar 10 '21 at 14:33
  • 2
    It requires the same fixed update rate on both machines. This does not need to be the frame rate per se. – DMGregory Mar 10 '21 at 14:34
  • Ok yes, game engine ticks must be fixed on both machines. But I don't see any value in having a frame rate that differs from this rate. Why redraw the same game state more than once? – Tom Davies Mar 10 '21 at 14:40
  • Great article, by the way. – Tom Davies Mar 10 '21 at 14:47
  • 1
  • ah yes. I have come across that Q&A before, and it's very good. but I don't see any advantage in my particular case. My game is not taxing on the computer - I'd expect any PC from the last 20 years to be able to run it at 60fps, even with many engine rollbacks. Rendering faster than 60fps is simply something I see no benefit in. So I'm fixing my frame rate. – Tom Davies Mar 10 '21 at 15:29

0 Answers0