# HG changeset patch # User Thibaut Girka # Date 1377887882 -7200 # Node ID 1f5156093785849a6712e36fadba19761c9f3e01 # Parent c034570ac7850817e3440214e8308ac5dee2c40b By default, only enable fps limiting if vsync doesn't do the job. diff --git a/eosd b/eosd --- a/eosd +++ b/eosd @@ -37,7 +37,7 @@ parser.add_argument('--save-replay', met parser.add_argument('--skip-replay', action='store_true', help='Skip the replay and start to play when it’s finished') parser.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses') parser.add_argument('--single-buffer', action='store_true', help='Disable double buffering') -parser.add_argument('--fps-limit', metavar='FPS', default=60, type=int, help='Set fps limit') +parser.add_argument('--fps-limit', metavar='FPS', default=-1, type=int, help='Set fps limit. A value of 0 disables fps limiting, while a negative value limits to 60 fps if and only if vsync doesn’t work.') parser.add_argument('--debug', action='store_true', help='Set unlimited continues, and perhaps other debug features.') parser.add_argument('--fixed-pipeline', action='store_true', help='Use the fixed pipeline instead of the new programmable one.') parser.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).') diff --git a/pytouhou/ui/window.pyx b/pytouhou/ui/window.pyx --- a/pytouhou/ui/window.pyx +++ b/pytouhou/ui/window.pyx @@ -24,7 +24,7 @@ IF USE_GLEW: from pytouhou.lib.opengl cimport glewInit -class Clock(object): +class Clock: def __init__(self, fps=None): self._target_fps = 0 self._ref_tick = 0 @@ -52,10 +52,14 @@ class Clock(object): self._ref_tick = current self._ref_frame = 0 - if self._fps_frame >= (self._target_fps or 60): + if self._fps_frame >= (self._target_fps if self._target_fps > 0 else 60): self._rate = self._fps_frame * 1000. / (current - self._fps_tick) self._fps_tick = current self._fps_frame = 0 + # If we are relying on vsync, but vsync doesn't work or is higher + # than 60 fps, limit ourselves to 60 fps. + if self._target_fps < 0 and self._rate > 64.: + self._target_fps = 60 self._ref_frame += 1 self._fps_frame += 1