0
\$\begingroup\$

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?

\$\endgroup\$
7
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – DMGregory
    Mar 10 '21 at 12:33
  • \$\begingroup\$ 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) \$\endgroup\$
    – Tom Davies
    Mar 10 '21 at 14:33
  • 2
    \$\begingroup\$ It requires the same fixed update rate on both machines. This does not need to be the frame rate per se. \$\endgroup\$
    – DMGregory
    Mar 10 '21 at 14:34
  • \$\begingroup\$ 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? \$\endgroup\$
    – Tom Davies
    Mar 10 '21 at 14:40
  • 1
    \$\begingroup\$ Fortunately we have Q&A on that very topic: What is the point of update independent rendering in a game loop? \$\endgroup\$
    – DMGregory
    Mar 10 '21 at 14:57

You must log in to answer this question.

Browse other questions tagged .